Skip to content

Commit

Permalink
rocksdb: fix crash due to uninitialized/stale ColumnFamilyHandle
Browse files Browse the repository at this point in the history
`CreateColumnFamilyWithImport()` expects that the value inside
handle is `nullptr`. This patch fixed a codepath where we pass
a stale handle left by destroyed column family.
  • Loading branch information
vishesh committed Feb 28, 2025
1 parent f786104 commit b66cf62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions fdbserver/KeyValueStoreRocksDB.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,7 @@ void RocksDBKeyValueStore::Writer::action(RestoreAction& a) {
ASSERT(db->DropColumnFamily(cf).ok());
db->DestroyColumnFamilyHandle(cf);
cfHandles.erase(cf);
cf = nullptr;
}

rocksdb::ExportImportFilesMetaData metaData = getMetaData(a.checkpoints[0]);
Expand Down
3 changes: 2 additions & 1 deletion fdbserver/KeyValueStoreShardedRocksDB.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ struct PhysicalShard {
const CheckpointFormat format = checkpoint.getFormat();
rocksdb::Status status;
if (format == DataMoveRocksCF) {
ASSERT(cf == nullptr);
rocksdb::ExportImportFilesMetaData metaData = getMetaData(checkpoint);
if (metaData.files.empty()) {
TraceEvent(SevInfo, "RocksDBRestoreEmptyShard")
Expand Down Expand Up @@ -2737,7 +2738,7 @@ struct ShardedRocksDBKeyValueStore : IKeyValueStore {
if (!metadata.files.empty() && SERVER_KNOBS->ROCKSDB_ENABLE_CHECKPOINT_VALIDATION) {
rocksdb::ImportColumnFamilyOptions importOptions;
importOptions.move_files = false;
rocksdb::ColumnFamilyHandle* handle;
rocksdb::ColumnFamilyHandle* handle{ nullptr };
const std::string cfName = deterministicRandom()->randomAlphaNumeric(8);
s = a.shardManager->getDb()->CreateColumnFamilyWithImport(
rocksdb::ColumnFamilyOptions(), cfName, importOptions, metadata, &handle);
Expand Down

0 comments on commit b66cf62

Please sign in to comment.