Skip to content

Commit

Permalink
Revert "chore: update rocksdb dependency to 0.22" (#12807)
Browse files Browse the repository at this point in the history
Reverts #12672

Attempt to fix regression related to disk usage.
  • Loading branch information
Longarithm authored Jan 27, 2025
1 parent c193875 commit 6618737
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 30 deletions.
33 changes: 25 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ ripemd = "0.1.1"
rkyv = "0.8.0"
rlimit = "0.7"
rlp = "0.5.2"
rocksdb = { version = "0.22.0", default-features = false, features = [
rocksdb = { version = "0.21.0", default-features = false, features = [
"snappy",
"lz4",
"zstd",
Expand Down
50 changes: 29 additions & 21 deletions core/store/src/db/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use crate::config::Mode;
use crate::db::{refcount, DBIterator, DBOp, DBSlice, DBTransaction, Database, StatsValue};
use crate::{metadata, metrics, DBCol, StoreConfig, StoreStatistics, Temperature};
use ::rocksdb::{
properties, BlockBasedOptions, Cache, ColumnFamily, Env, IteratorMode, Options, ReadOptions,
WriteBatch, DB,
BlockBasedOptions, Cache, ColumnFamily, Env, IteratorMode, Options, ReadOptions, WriteBatch, DB,
};
use anyhow::Context;
use itertools::Itertools;
use std::io;
use std::ops::Deref;
use std::path::Path;
use std::sync::LazyLock;
use strum::IntoEnumIterator;
Expand All @@ -19,23 +19,28 @@ pub(crate) mod snapshot;
/// List of integer RocksDB properties we’re reading when collecting statistics.
///
/// In the end, they are exported as Prometheus metrics.
static CF_PROPERTY_NAMES: LazyLock<Vec<properties::PropertyName>> = LazyLock::new(|| {
[
properties::LIVE_SST_FILES_SIZE,
properties::ESTIMATE_LIVE_DATA_SIZE,
properties::COMPACTION_PENDING,
properties::NUM_RUNNING_COMPACTIONS,
properties::ESTIMATE_PENDING_COMPACTION_BYTES,
properties::ESTIMATE_TABLE_READERS_MEM,
properties::BLOCK_CACHE_CAPACITY,
properties::BLOCK_CACHE_USAGE,
properties::CUR_SIZE_ACTIVE_MEM_TABLE,
properties::SIZE_ALL_MEM_TABLES,
]
.into_iter()
.map(properties::PropName::to_owned)
.chain((0..7).map(properties::num_files_at_level))
.collect()
static CF_PROPERTY_NAMES: LazyLock<Vec<std::ffi::CString>> = LazyLock::new(|| {
use ::rocksdb::properties;
let mut ret = Vec::new();
ret.extend_from_slice(
&[
properties::LIVE_SST_FILES_SIZE,
properties::ESTIMATE_LIVE_DATA_SIZE,
properties::COMPACTION_PENDING,
properties::NUM_RUNNING_COMPACTIONS,
properties::ESTIMATE_PENDING_COMPACTION_BYTES,
properties::ESTIMATE_TABLE_READERS_MEM,
properties::BLOCK_CACHE_CAPACITY,
properties::BLOCK_CACHE_USAGE,
properties::CUR_SIZE_ACTIVE_MEM_TABLE,
properties::SIZE_ALL_MEM_TABLES,
]
.map(std::ffi::CStr::to_owned),
);
for level in 0..=6 {
ret.push(properties::num_files_at_level(level));
}
ret
});

pub struct RocksDB {
Expand Down Expand Up @@ -663,7 +668,7 @@ impl RocksDB {

/// Gets every int property in CF_PROPERTY_NAMES for every column in DBCol.
fn get_cf_statistics(&self, result: &mut StoreStatistics) {
for prop_name in CF_PROPERTY_NAMES.iter() {
for prop_name in CF_PROPERTY_NAMES.deref() {
let values = self
.cf_handles()
.filter_map(|(col, handle)| {
Expand All @@ -672,7 +677,10 @@ impl RocksDB {
})
.collect::<Vec<_>>();
if !values.is_empty() {
result.data.push((prop_name.as_str().into(), values));
// TODO(mina86): Once const_str_from_utf8 is stabilised we might

Check warning on line 680 in core/store/src/db/rocksdb.rs

View workflow job for this annotation

GitHub Actions / spellcheck

Unknown word (stabilised)
// be able convert this runtime UTF-8 validation into const.
let stat_name = prop_name.to_str().unwrap();
result.data.push((stat_name.to_string(), values));
}
}
}
Expand Down

0 comments on commit 6618737

Please sign in to comment.