Update to rocksdb 0.14 and set max wal size (#9668) (#9688) (#9708)

Co-authored-by: sakridge <sakridge@gmail.com>
This commit is contained in:
Michael Vines
2020-04-24 10:43:01 -07:00
committed by GitHub
parent 940bf7081a
commit 9558628537
2 changed files with 11 additions and 8 deletions

View File

@ -50,7 +50,7 @@ lazy_static = "1.4.0"
[dependencies.rocksdb] [dependencies.rocksdb]
# Avoid the vendored bzip2 within rocksdb-sys that can cause linker conflicts # Avoid the vendored bzip2 within rocksdb-sys that can cause linker conflicts
# when also using the bzip2 crate # when also using the bzip2 crate
version = "0.13.0" version = "0.14.0"
default-features = false default-features = false
features = ["lz4"] features = ["lz4"]

View File

@ -247,12 +247,12 @@ impl Rocks {
IteratorMode::Start => RocksIteratorMode::Start, IteratorMode::Start => RocksIteratorMode::Start,
IteratorMode::End => RocksIteratorMode::End, IteratorMode::End => RocksIteratorMode::End,
}; };
let iter = self.0.iterator_cf(cf, iterator_mode)?; let iter = self.0.iterator_cf(cf, iterator_mode);
Ok(iter) Ok(iter)
} }
fn raw_iterator_cf(&self, cf: &ColumnFamily) -> Result<DBRawIterator> { fn raw_iterator_cf(&self, cf: &ColumnFamily) -> Result<DBRawIterator> {
let raw_iter = self.0.raw_iterator_cf(cf)?; let raw_iter = self.0.raw_iterator_cf(cf);
Ok(raw_iter) Ok(raw_iter)
} }
@ -783,13 +783,12 @@ where
impl<'a> WriteBatch<'a> { impl<'a> WriteBatch<'a> {
pub fn put_bytes<C: Column + ColumnName>(&mut self, key: C::Index, bytes: &[u8]) -> Result<()> { pub fn put_bytes<C: Column + ColumnName>(&mut self, key: C::Index, bytes: &[u8]) -> Result<()> {
self.write_batch self.write_batch
.put_cf(self.get_cf::<C>(), &C::key(key), bytes)?; .put_cf(self.get_cf::<C>(), &C::key(key), bytes);
Ok(()) Ok(())
} }
pub fn delete<C: Column + ColumnName>(&mut self, key: C::Index) -> Result<()> { pub fn delete<C: Column + ColumnName>(&mut self, key: C::Index) -> Result<()> {
self.write_batch self.write_batch.delete_cf(self.get_cf::<C>(), &C::key(key));
.delete_cf(self.get_cf::<C>(), &C::key(key))?;
Ok(()) Ok(())
} }
@ -800,7 +799,7 @@ impl<'a> WriteBatch<'a> {
) -> Result<()> { ) -> Result<()> {
let serialized_value = serialize(&value)?; let serialized_value = serialize(&value)?;
self.write_batch self.write_batch
.put_cf(self.get_cf::<C>(), &C::key(key), &serialized_value)?; .put_cf(self.get_cf::<C>(), &C::key(key), &serialized_value);
Ok(()) Ok(())
} }
@ -816,7 +815,7 @@ impl<'a> WriteBatch<'a> {
to: C::Index, to: C::Index,
) -> Result<()> { ) -> Result<()> {
self.write_batch self.write_batch
.delete_range_cf(cf, C::key(from), C::key(to))?; .delete_range_cf(cf, C::key(from), C::key(to));
Ok(()) Ok(())
} }
} }
@ -844,5 +843,9 @@ fn get_db_options() -> Options {
options.create_missing_column_families(true); options.create_missing_column_families(true);
// A good value for this is the number of cores on the machine // A good value for this is the number of cores on the machine
options.increase_parallelism(num_cpus::get() as i32); options.increase_parallelism(num_cpus::get() as i32);
// Set max total wal size to 4G.
options.set_max_total_wal_size(4 * 1024 * 1024 * 1024);
options options
} }