diff --git a/kvrocks.conf b/kvrocks.conf index 33e15083838..e443251a58b 100644 --- a/kvrocks.conf +++ b/kvrocks.conf @@ -648,7 +648,7 @@ migrate-batch-rate-limit-mb 16 # If set to 1, we skip blockcache dtor to speed up shutdown # # Default: 0 -# fast_shutdown 0 +# skip-block-cache-deallocation-on-close 0 ################################ ROCKSDB ##################################### diff --git a/src/config/config.cc b/src/config/config.cc index c5b16621b1d..b670c38763e 100644 --- a/src/config/config.cc +++ b/src/config/config.cc @@ -239,7 +239,7 @@ Config::Config() { {"json-storage-format", false, new EnumField(&json_storage_format, json_storage_formats, JsonStorageFormat::JSON)}, {"txn-context-enabled", true, new YesNoField(&txn_context_enabled, false)}, - {"fast_shutdown", false, new YesNoField(&fast_shutdown, false)}, + {"skip-block-cache-deallocation-on-close", false, new YesNoField(&skip_block_cache_deallocation_on_close, false)}, /* rocksdb options */ {"rocksdb.compression", false, diff --git a/src/config/config.h b/src/config/config.h index 9243e11d3e7..1e095bd1a8c 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -175,7 +175,7 @@ struct Config { // Enable transactional mode in engine::Context bool txn_context_enabled = false; - bool fast_shutdown = false; + bool skip_block_cache_deallocation_on_close = false; struct RocksDB { int block_size; diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 2dc464fed95..40ad5ac3f29 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -88,6 +88,13 @@ Storage::Storage(Config *config) Storage::~Storage() { DestroyBackup(); CloseDB(); + SkipBlockCacheDeallocationOnClose(); +} + +void Storage::SkipBlockCacheDeallocationOnClose() { + if (config_->skip_block_cache_deallocation_on_close) { + shared_block_cache_->DisownData(); + } } void Storage::CloseDB() { @@ -98,9 +105,6 @@ void Storage::CloseDB() { db_->SyncWAL(); rocksdb::CancelAllBackgroundWork(db_.get(), true); for (auto handle : cf_handles_) db_->DestroyColumnFamilyHandle(handle); - if (config_->fast_shutdown) { - shared_block_cache_->DisownData(); - } db_ = nullptr; } diff --git a/src/storage/storage.h b/src/storage/storage.h index aff2c0a6598..580ecaf00ee 100644 --- a/src/storage/storage.h +++ b/src/storage/storage.h @@ -213,6 +213,7 @@ class Storage { void SetWriteOptions(const Config::RocksDB::WriteOptions &config); Status Open(DBOpenMode mode = kDBOpenModeDefault); void CloseDB(); + void SkipBlockCacheDeallocationOnClose(); bool IsEmptyDB(); void EmptyDB(); rocksdb::BlockBasedTableOptions InitTableOptions();