Skip to content

Commit

Permalink
fix: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghenshui committed Dec 3, 2024
1 parent d39e5b9 commit f5e346a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion kvrocks.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 #####################################

Expand Down
2 changes: 1 addition & 1 deletion src/config/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Config::Config() {
{"json-storage-format", false,
new EnumField<JsonStorageFormat>(&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,
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions src/storage/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/storage/storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f5e346a

Please sign in to comment.