Skip to content

Commit b67149a

Browse files
hx235facebook-github-bot
authored andcommitted
Skip DumpStats() on dropped CF (#13900)
Summary: **Context/Summary:** DumpStats() do not skip dropped CF and can run into a seg fault like below ``` 2025-08-23T06:44:05.0469230Z �[0;32m[ RUN ] �[mFormatLatest/ColumnFamilyTest.LiveIteratorWithDroppedColumnFamily/0 2025-08-23T06:44:05.0470050Z Received signal 11 (Segmentation fault: 11) 2025-08-23T06:44:05.0470510Z #0 0x7000069305e0 2025-08-23T06:44:05.0471070Z #1 rocksdb::DBImpl::DumpStats() (in librocksdb.10.6.0.dylib) (db_impl.cc:1076) ``` This PR skipped it. Pull Request resolved: #13900 Test Plan: - Deterministically repro-ed the seg fault before the fix and ensure it doesn't happen after the fix ``` diff --git a/db/column_family_test.cc b/db/column_family_test.cc index 3a2ca06..f57d6f757 100644 --- a/db/column_family_test.cc +++ b/db/column_family_test.cc @@ -2372,11 +2372,17 @@ TEST_P(ColumnFamilyTest, LiveIteratorWithDroppedColumnFamily) { int kKeysNum = 10000; PutRandomData(1, kKeysNum, 100); { + ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency( + {{"PostDrop", "BeforeAccessCFD"}, {"PostAccessCFD", "BeforeGo"}}); + + ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); std::unique_ptr<Iterator> iterator( db_->NewIterator(ReadOptions(), handles_[1])); iterator->SeekToFirst(); DropColumnFamilies({1}); + TEST_SYNC_POINT("PostDrop"); + TEST_SYNC_POINT("BeforeGo"); // Make sure iterator created can still be used. int count = 0; @@ -2386,6 +2392,9 @@ TEST_P(ColumnFamilyTest, LiveIteratorWithDroppedColumnFamily) { } ASSERT_OK(iterator->status()); ASSERT_EQ(count, kKeysNum); + + ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing(); + ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks(); } Reopen(); diff --git a/db/db_impl/db_impl.cc b/db/db_impl/db_impl.cc index a8e4f5f..a8a0499c0 100644 --- a/db/db_impl/db_impl.cc +++ b/db/db_impl/db_impl.cc @@ -1073,8 +1073,10 @@ void DBImpl::DumpStats() { continue; } - auto* table_factory = - cfd->GetCurrentMutableCFOptions().table_factory.get(); + TEST_SYNC_POINT("BeforeAccessCFD"); + auto moptions = cfd->GetCurrentMutableCFOptions(); + auto* table_factory = moptions.table_factory.get(); + TEST_SYNC_POINT("PostAccessCFD"); assert(table_factory != nullptr); // FIXME: need to a shared_ptr if/when block_cache is going to be mutable Cache* cache = ~ ``` Reviewed By: archang19 Differential Revision: D81003739 Pulled By: hx235 fbshipit-source-id: bdf3c4cc45988f43e79ebc191a20af5b70ac289f
1 parent d399165 commit b67149a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

db/db_impl/db_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ void DBImpl::DumpStats() {
10691069
{
10701070
InstrumentedMutexLock l(&mutex_);
10711071
for (auto cfd : versions_->GetRefedColumnFamilySet()) {
1072-
if (!cfd->initialized()) {
1072+
if (!cfd->initialized() || cfd->IsDropped()) {
10731073
continue;
10741074
}
10751075

0 commit comments

Comments
 (0)