From 2256dab1352abfd9f4388c37d509b9cd02a70b46 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Tue, 13 Mar 2018 14:46:41 -0700 Subject: [PATCH] fix flaky DBSSTTest.DeleteSchedulerMultipleDBPaths Summary: I landed #3544 which made this test flaky. The reason was the files scheduled for deletion sometimes went through the trash-marking process, and sometimes were deleted directly. Our counter only bumped on the former code path, so if the latter code path was used, we'd miss counting a file deleted by deletion scheduler. This PR also bumps the counter in the latter code path. Closes https://github.com/facebook/rocksdb/pull/3593 Differential Revision: D7226173 Pulled By: yiwu-arbug fbshipit-source-id: 81ab44c60834df6ff88db1d73ea34e26c6e93c39 --- db/db_sst_test.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/db/db_sst_test.cc b/db/db_sst_test.cc index b6d55e27d8b..a64f6a9245a 100644 --- a/db/db_sst_test.cc +++ b/db/db_sst_test.cc @@ -409,6 +409,11 @@ TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) { rocksdb::SyncPoint::GetInstance()->SetCallBack( "DeleteScheduler::DeleteTrashFile:DeleteFile", [&](void* arg) { bg_delete_file++; }); + // The deletion scheduler sometimes skips marking file as trash according to + // a heuristic. In that case the deletion will go through the below SyncPoint. + rocksdb::SyncPoint::GetInstance()->SetCallBack( + "DeleteScheduler::DeleteFile", + [&](void* arg) { bg_delete_file++; }); rocksdb::SyncPoint::GetInstance()->EnableProcessing(); Options options = CurrentOptions(); @@ -461,15 +466,15 @@ TEST_F(DBSSTTest, DeleteSchedulerMultipleDBPaths) { sfm->WaitForEmptyTrash(); ASSERT_EQ(bg_delete_file, 8); - // Compaction will delete and regenerate a file from L1 in second db path. It - // should still be cleaned up via delete scheduler. + // Compaction will delete both files and regenerate a file in L1 in second + // db path. The deleted files should still be cleaned up via delete scheduler. compact_options.bottommost_level_compaction = BottommostLevelCompaction::kForce; ASSERT_OK(db_->CompactRange(compact_options, nullptr, nullptr)); ASSERT_EQ("0,1", FilesPerLevel(0)); sfm->WaitForEmptyTrash(); - ASSERT_EQ(bg_delete_file, 9); + ASSERT_EQ(bg_delete_file, 10); rocksdb::SyncPoint::GetInstance()->DisableProcessing(); }