Deflake DBCompactionTest.CancelCompactionWaitingOnConflict (#11318)

Summary:
In DBCompactionTest::CancelCompactionWaitingOnConflict, when generating SST files to trigger a compaction, we don't wait after each file, which may cause multiple memtables going to the same SST file, causing insufficient files to trigger the compaction. We do the waiting instead, except the last one, which would trigger compaction.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11318

Test Plan: Run DBCompactionTest.CancelCompactionWaitingOnConflict multiple times.

Reviewed By: ajkr

Differential Revision: D44267273

fbshipit-source-id: 86af49b05fc67ea3335312f0f5f3d22df1520bf8
oxigraph-8.3.2
sdong 2 years ago committed by Facebook GitHub Bot
parent cea81cad66
commit b92bc04ab0
  1. 5
      db/db_compaction_test.cc

@ -3613,7 +3613,10 @@ TEST_F(DBCompactionTest, CancelCompactionWaitingOnConflict) {
Random rnd(301); Random rnd(301);
for (int i = 0; i < kNumSortedRuns; ++i) { for (int i = 0; i < kNumSortedRuns; ++i) {
int key_idx = 0; int key_idx = 0;
GenerateNewFile(&rnd, &key_idx, true /* nowait */); // We hold the compaction from happening, so when generating the last SST
// file, we cannot wait. Otherwise, we'll hit a deadlock.
GenerateNewFile(&rnd, &key_idx,
(i == kNumSortedRuns - 1) ? true : false /* nowait */);
} }
auto_compaction_sleeping_task.WaitUntilSleeping(); auto_compaction_sleeping_task.WaitUntilSleeping();

Loading…
Cancel
Save