From 1583cb402eb6f52adac0261cb3766b47aac3078e Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Wed, 15 May 2019 15:13:44 -0700 Subject: [PATCH] Fix a flaky test with test sync point (#5310) Summary: If DB is opened with `avoid_unnecessary_blocking_io` being true, then `~ColumnFamilyHandleImpl` enqueues a purge request and schedules a background thread to perform the deletion. Without test sync point, whether the SST file is purged or not at a later point in time is not deterministic. If the SST does not exist, it will cause an assertion failure. How to reproduce: ``` $git checkout 6492430eaf1a13730eec81321528558cbf486c96 $make -j20 deletefile_test $gtest-parallel --repeat 1000 --worker 16 ./deletefile_test --gtest_filter=DeleteFileTest.BackgroundPurgeCFDropTest ``` The test may fail a few times. With changes made in this PR, repeat the above commands, and the test should not fail. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5310 Differential Revision: D15361136 Pulled By: riversand963 fbshipit-source-id: c4308d5f8da83472c893bf7f8ceed347fbfa850f --- db/deletefile_test.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/db/deletefile_test.cc b/db/deletefile_test.cc index 3ae464c58..54bab8479 100644 --- a/db/deletefile_test.cc +++ b/db/deletefile_test.cc @@ -305,6 +305,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeCFDropTest) { &sleeping_task_after, Env::Priority::HIGH); // 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"); // Execute background purges. sleeping_task_after.WakeUp(); @@ -318,6 +319,13 @@ TEST_F(DeleteFileTest, BackgroundPurgeCFDropTest) { do_test(false); } + SyncPoint::GetInstance()->DisableProcessing(); + SyncPoint::GetInstance()->ClearAllCallBacks(); + SyncPoint::GetInstance()->LoadDependency( + {{"DeleteFileTest::BackgroundPurgeCFDropTest:1", + "DBImpl::BGWorkPurge:start"}}); + SyncPoint::GetInstance()->EnableProcessing(); + options_.avoid_unnecessary_blocking_io = true; ASSERT_OK(ReopenDB(false)); { @@ -326,6 +334,7 @@ TEST_F(DeleteFileTest, BackgroundPurgeCFDropTest) { } CloseDB(); + SyncPoint::GetInstance()->DisableProcessing(); } // This test is to reproduce a bug that read invalid ReadOption in iterator