Skip to content

Commit

Permalink
unit tests: fix DisableMultiManualCompaction in db_compaction_test (#611
Browse files Browse the repository at this point in the history
)

The test sometimes failed in CI since the test code assumed there was
only 1 bg compaction thread which needed to be blocked but in #194,
the default was changed to 8 so the fix is simply to block all the bg threads.
  • Loading branch information
Yuval-Ariel authored and udi-speedb committed Dec 5, 2023
1 parent 0d82ee2 commit a79bda7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* build: Windows compilation fix (#568).
* Logger: fix Block cache stats trace by spacing it from the last trace (#578).
* WriteController: move the class to public interface which should have been done under #346.
* unit tests: fix DBCompactionTest.DisableMultiManualCompaction by blocking all bg compaction threads which increased by default to 8 in #194.

## Fig v2.5.0 (06/14/2023)
Based on RocksDB 8.1.1
Expand Down
17 changes: 12 additions & 5 deletions db/db_compaction_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9100,9 +9100,13 @@ TEST_F(DBCompactionTest, DisableMultiManualCompaction) {
MoveFilesToLevel(1);

// Block compaction queue
test::SleepingBackgroundTask sleeping_task_low;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task_low,
Env::Priority::LOW);
std::vector<test::SleepingBackgroundTask> sleeping_task_low(
std::max(1, env_->GetBackgroundThreads(Env::Priority::LOW)));

for (auto& sleeping_task : sleeping_task_low) {
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask, &sleeping_task,
Env::Priority::LOW);
}

port::Thread compact_thread1([&]() {
CompactRangeOptions cro;
Expand Down Expand Up @@ -9133,8 +9137,11 @@ TEST_F(DBCompactionTest, DisableMultiManualCompaction) {
compact_thread1.join();
compact_thread2.join();

sleeping_task_low.WakeUp();
sleeping_task_low.WaitUntilDone();
for (auto& sleeping_task : sleeping_task_low) {
sleeping_task.WakeUp();
sleeping_task.WaitUntilDone();
}

ASSERT_OK(dbfull()->TEST_WaitForCompact());
}

Expand Down

0 comments on commit a79bda7

Please sign in to comment.