@@ -1308,16 +1308,21 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13081308 explicit BlobDBJobLevelEventListenerTest (EventListenerTest* test)
13091309 : test_(test), call_count_(0 ) {}
13101310
1311- const VersionStorageInfo* GetVersionStorageInfo () const {
1312- VersionSet* const versions = test_->dbfull ()->GetVersionSet ();
1311+ // NOTE: it's not safe to rely on test_->db_ for these functions because
1312+ // the DB may be in the process of closing when these are called, and the
1313+ // unique_ptr is set to nullptr before invoking ~DB()
1314+
1315+ const VersionStorageInfo* GetVersionStorageInfo (DB* db) const {
1316+ DBImpl* db_impl = static_cast_with_check<DBImpl>(db);
1317+ VersionSet* const versions = db_impl->GetVersionSet ();
13131318 assert (versions);
13141319
13151320 ColumnFamilyData* const cfd = versions->GetColumnFamilySet ()->GetDefault ();
13161321 EXPECT_NE (cfd, nullptr );
13171322
1318- test_-> dbfull () ->TEST_LockMutex ();
1323+ db_impl ->TEST_LockMutex ();
13191324 Version* const current = cfd->current ();
1320- test_-> dbfull () ->TEST_UnlockMutex ();
1325+ db_impl ->TEST_UnlockMutex ();
13211326 EXPECT_NE (current, nullptr );
13221327
13231328 const VersionStorageInfo* const storage_info = current->storage_info ();
@@ -1327,8 +1332,9 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13271332 }
13281333
13291334 void CheckBlobFileAdditions (
1335+ DB* db,
13301336 const std::vector<BlobFileAdditionInfo>& blob_file_addition_infos) const {
1331- const auto * vstorage = GetVersionStorageInfo ();
1337+ const auto * vstorage = GetVersionStorageInfo (db );
13321338
13331339 EXPECT_FALSE (blob_file_addition_infos.empty ());
13341340
@@ -1356,7 +1362,7 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13561362 return result;
13571363 }
13581364
1359- void OnFlushCompleted (DB* /* db */ , const FlushJobInfo& info) override {
1365+ void OnFlushCompleted (DB* db , const FlushJobInfo& info) override {
13601366 {
13611367 std::lock_guard<std::mutex> lock (mutex_);
13621368 IncreaseCallCount (/* mutex_locked*/ true );
@@ -1365,16 +1371,15 @@ class BlobDBJobLevelEventListenerTest : public EventListener {
13651371
13661372 EXPECT_EQ (info.blob_compression_type , kNoCompression );
13671373
1368- CheckBlobFileAdditions (info.blob_file_addition_infos );
1374+ CheckBlobFileAdditions (db, info.blob_file_addition_infos );
13691375 }
13701376
1371- void OnCompactionCompleted (DB* /* db*/ ,
1372- const CompactionJobInfo& info) override {
1377+ void OnCompactionCompleted (DB* db, const CompactionJobInfo& info) override {
13731378 IncreaseCallCount (/* mutex_locked*/ false );
13741379
13751380 EXPECT_EQ (info.blob_compression_type , kNoCompression );
13761381
1377- CheckBlobFileAdditions (info.blob_file_addition_infos );
1382+ CheckBlobFileAdditions (db, info.blob_file_addition_infos );
13781383
13791384 EXPECT_FALSE (info.blob_file_garbage_infos .empty ());
13801385
0 commit comments