Skip to content

Commit

Permalink
db: Fixes for db_test2 and deletefile_test
Browse files Browse the repository at this point in the history
Following the change of scheduling purges with low priority, instead of high priority,
tests that tried to block purges from happening by taking up
a slot in the high priority queue, had to instead be scheduled with low piority too.
  • Loading branch information
AmnonHanuhov committed Sep 11, 2022
1 parent ead8128 commit 30526cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions db/db_test2.cc
Expand Up @@ -5896,10 +5896,12 @@ TEST_F(DBTest2, BackgroundPurgeTest) {
size_t value = options.write_buffer_manager->memory_usage();
ASSERT_GT(value, base_value);

db_->GetEnv()->SetBackgroundThreads(1, Env::Priority::HIGH);
// Take up a slot in the low priority pool
// in order to prevent a purge from running when the iterator is deleted.
db_->GetEnv()->SetBackgroundThreads(1, Env::Priority::LOW);
test::SleepingBackgroundTask sleeping_task_after;
db_->GetEnv()->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);
delete iter;

Env::Default()->SleepForMicroseconds(100000);
Expand All @@ -5911,7 +5913,7 @@ TEST_F(DBTest2, BackgroundPurgeTest) {

test::SleepingBackgroundTask sleeping_task_after2;
db_->GetEnv()->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after2, Env::Priority::HIGH);
&sleeping_task_after2, Env::Priority::LOW);
sleeping_task_after2.WakeUp();
sleeping_task_after2.WaitUntilDone();

Expand Down
8 changes: 4 additions & 4 deletions db/deletefile_test.cc
Expand Up @@ -252,11 +252,11 @@ TEST_F(DeleteFileTest, BackgroundPurgeIteratorTest) {
CheckFileTypeCounts(dbname_, 0, 3, 1);
test::SleepingBackgroundTask sleeping_task_before;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_before, Env::Priority::HIGH);
&sleeping_task_before, Env::Priority::LOW);
delete itr;
test::SleepingBackgroundTask sleeping_task_after;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);

// Make sure no purges are executed foreground
CheckFileTypeCounts(dbname_, 0, 3, 1);
Expand Down Expand Up @@ -334,7 +334,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeCFDropTest) {
delete cfh;
test::SleepingBackgroundTask sleeping_task_after;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);
// If background purge is enabled, the file should still be there.
CheckFileTypeCounts(dbname_, 0, bg_purge ? 1 : 0, 1);
TEST_SYNC_POINT("DeleteFileTest::BackgroundPurgeCFDropTest:1");
Expand Down Expand Up @@ -403,7 +403,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeCopyOptions) {

test::SleepingBackgroundTask sleeping_task_after;
env_->Schedule(&test::SleepingBackgroundTask::DoSleepTask,
&sleeping_task_after, Env::Priority::HIGH);
&sleeping_task_after, Env::Priority::LOW);

// Make sure all background purges are executed
sleeping_task_after.WakeUp();
Expand Down

0 comments on commit 30526cb

Please sign in to comment.