@ -1868,126 +1868,6 @@ TEST_F(ColumnFamilyTest, SameCFManualAutomaticCompactionsLevel) {
}
}
// This test checks for automatic getting a conflict if there is a
// manual which has not yet been scheduled.
// The manual compaction waits in NotScheduled
// We generate more files and then trigger an automatic compaction
// This will wait because there is an unscheduled manual compaction.
// Once the conflict is hit, the manual compaction starts and ends
// Then another automatic will start and end.
TEST_F ( ColumnFamilyTest , SameCFManualAutomaticConflict ) {
Open ( ) ;
CreateColumnFamilies ( { " one " } ) ;
ColumnFamilyOptions default_cf , one ;
db_options_ . max_open_files = 20 ; // only 10 files in file cache
db_options_ . max_background_compactions = 3 ;
default_cf . compaction_style = kCompactionStyleLevel ;
default_cf . num_levels = 3 ;
default_cf . write_buffer_size = 64 < < 10 ; // 64KB
default_cf . target_file_size_base = 30 < < 10 ;
default_cf . max_compaction_bytes = default_cf . target_file_size_base * 1100 ;
BlockBasedTableOptions table_options ;
table_options . no_block_cache = true ;
default_cf . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ;
one . compaction_style = kCompactionStyleUniversal ;
one . num_levels = 1 ;
// trigger compaction if there are >= 4 files
one . level0_file_num_compaction_trigger = 4 ;
one . write_buffer_size = 120000 ;
Reopen ( { default_cf , one } ) ;
// make sure all background compaction jobs can be scheduled
auto stop_token =
dbfull ( ) - > TEST_write_controler ( ) . GetCompactionPressureToken ( ) ;
// SETUP column family "one" -- universal style
for ( int i = 0 ; i < one . level0_file_num_compaction_trigger - 2 ; + + i ) {
PutRandomData ( 1 , 10 , 12000 , true ) ;
PutRandomData ( 1 , 1 , 10 , true ) ;
WaitForFlush ( 1 ) ;
AssertFilesPerLevel ( ToString ( i + 1 ) , 1 ) ;
}
bool cf_1_1 = true ;
bool cf_1_2 = true ;
rocksdb : : SyncPoint : : GetInstance ( ) - > LoadDependency (
{ { " DBImpl::BackgroundCompaction()::Conflict " ,
" ColumnFamilyTest::ManualAutoCon:7 " } ,
{ " ColumnFamilyTest::ManualAutoCon:9 " ,
" ColumnFamilyTest::ManualAutoCon:8 " } ,
{ " ColumnFamilyTest::ManualAutoCon:2 " ,
" ColumnFamilyTest::ManualAutoCon:6 " } ,
{ " ColumnFamilyTest::ManualAutoCon:4 " ,
" ColumnFamilyTest::ManualAutoCon:5 " } ,
{ " ColumnFamilyTest::ManualAutoCon:1 " ,
" ColumnFamilyTest::ManualAutoCon:2 " } ,
{ " ColumnFamilyTest::ManualAutoCon:1 " ,
" ColumnFamilyTest::ManualAutoCon:3 " } } ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > SetCallBack (
" DBImpl::BackgroundCompaction:NonTrivial:AfterRun " , [ & ] ( void * arg ) {
if ( cf_1_1 ) {
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:4 " ) ;
cf_1_1 = false ;
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:3 " ) ;
} else if ( cf_1_2 ) {
cf_1_2 = false ;
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:2 " ) ;
}
} ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > SetCallBack (
" DBImpl::RunManualCompaction:NotScheduled " , [ & ] ( void * arg ) {
InstrumentedMutex * mutex = static_cast < InstrumentedMutex * > ( arg ) ;
mutex - > Unlock ( ) ;
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:9 " ) ;
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:7 " ) ;
mutex - > Lock ( ) ;
} ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
rocksdb : : port : : Thread threads ( [ & ] {
CompactRangeOptions compact_options ;
compact_options . exclusive_manual_compaction = false ;
ASSERT_OK (
db_ - > CompactRange ( compact_options , handles_ [ 1 ] , nullptr , nullptr ) ) ;
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:6 " ) ;
} ) ;
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:8 " ) ;
WaitForFlush ( 1 ) ;
// Add more L0 files and force automatic compaction
for ( int i = 0 ; i < one . level0_file_num_compaction_trigger ; + + i ) {
PutRandomData ( 1 , 10 , 12000 , true ) ;
PutRandomData ( 1 , 1 , 10 , true ) ;
WaitForFlush ( 1 ) ;
AssertFilesPerLevel ( ToString ( one . level0_file_num_compaction_trigger + i ) ,
1 ) ;
}
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:5 " ) ;
// Add more L0 files and force automatic compaction
for ( int i = 0 ; i < one . level0_file_num_compaction_trigger ; + + i ) {
PutRandomData ( 1 , 10 , 12000 , true ) ;
PutRandomData ( 1 , 1 , 10 , true ) ;
WaitForFlush ( 1 ) ;
}
TEST_SYNC_POINT ( " ColumnFamilyTest::ManualAutoCon:1 " ) ;
threads . join ( ) ;
WaitForCompaction ( ) ;
// VERIFY compaction "one"
ASSERT_LE ( NumTableFilesAtLevel ( 0 , 1 ) , 3 ) ;
// Compare against saved keys
std : : set < std : : string > : : iterator key_iter = keys_ . begin ( ) ;
while ( key_iter ! = keys_ . end ( ) ) {
ASSERT_NE ( " NOT_FOUND " , Get ( 1 , * key_iter ) ) ;
key_iter + + ;
}
}
// In this test, we generate enough files to trigger automatic compactions.
// The automatic compaction waits in NonTrivial:AfterRun
// We generate more files and then trigger an automatic compaction