@ -14,9 +14,10 @@
# include "rocksdb/experimental.h"
# include "rocksdb/experimental.h"
# include "rocksdb/sst_file_writer.h"
# include "rocksdb/sst_file_writer.h"
# include "rocksdb/utilities/convenience.h"
# include "rocksdb/utilities/convenience.h"
# include "test_util/fault_injection_test_env.h"
# include "test_util/sync_point.h"
# include "test_util/sync_point.h"
# include "util/concurrent_task_limiter_impl.h"
# include "util/concurrent_task_limiter_impl.h"
# include "util/random.h"
# include "utilities/fault_injection_env.h"
namespace ROCKSDB_NAMESPACE {
namespace ROCKSDB_NAMESPACE {
@ -295,7 +296,7 @@ TEST_P(DBCompactionTestWithParam, CompactionDeletionTrigger) {
const int kTestSize = kCDTKeysPerBuffer * 1024 ;
const int kTestSize = kCDTKeysPerBuffer * 1024 ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int k = 0 ; k < kTestSize ; + + k ) {
for ( int k = 0 ; k < kTestSize ; + + k ) {
values . push_back ( RandomString ( & rnd , kCDTValueSize ) ) ;
values . push_back ( rnd . RandomString ( kCDTValueSize ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
}
}
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
@ -343,7 +344,7 @@ TEST_P(DBCompactionTestWithParam, CompactionsPreserveDeletes) {
const int kTestSize = kCDTKeysPerBuffer ;
const int kTestSize = kCDTKeysPerBuffer ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int k = 0 ; k < kTestSize ; + + k ) {
for ( int k = 0 ; k < kTestSize ; + + k ) {
values . push_back ( RandomString ( & rnd , kCDTValueSize ) ) ;
values . push_back ( rnd . RandomString ( kCDTValueSize ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
}
}
@ -408,7 +409,7 @@ TEST_F(DBCompactionTest, SkipStatsUpdateTest) {
const int kTestSize = kCDTKeysPerBuffer * 512 ;
const int kTestSize = kCDTKeysPerBuffer * 512 ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int k = 0 ; k < kTestSize ; + + k ) {
for ( int k = 0 ; k < kTestSize ; + + k ) {
values . push_back ( RandomString ( & rnd , kCDTValueSize ) ) ;
values . push_back ( rnd . RandomString ( kCDTValueSize ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
}
}
@ -555,7 +556,7 @@ TEST_P(DBCompactionTestWithParam, CompactionDeletionTriggerReopen) {
const int kTestSize = kCDTKeysPerBuffer * 512 ;
const int kTestSize = kCDTKeysPerBuffer * 512 ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int k = 0 ; k < kTestSize ; + + k ) {
for ( int k = 0 ; k < kTestSize ; + + k ) {
values . push_back ( RandomString ( & rnd , kCDTValueSize ) ) ;
values . push_back ( rnd . RandomString ( kCDTValueSize ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
}
}
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
@ -673,7 +674,7 @@ TEST_F(DBCompactionTest, DisableStatsUpdateReopen) {
const int kTestSize = kCDTKeysPerBuffer * 512 ;
const int kTestSize = kCDTKeysPerBuffer * 512 ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int k = 0 ; k < kTestSize ; + + k ) {
for ( int k = 0 ; k < kTestSize ; + + k ) {
values . push_back ( RandomString ( & rnd , kCDTValueSize ) ) ;
values . push_back ( rnd . RandomString ( kCDTValueSize ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
}
}
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
@ -736,7 +737,7 @@ TEST_P(DBCompactionTestWithParam, CompactionTrigger) {
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
// Write 100KB (100 values, each 1K)
// Write 100KB (100 values, each 1K)
for ( int i = 0 ; i < kNumKeysPerFile ; i + + ) {
for ( int i = 0 ; i < kNumKeysPerFile ; i + + ) {
values . push_back ( RandomString ( & rnd , 990 ) ) ;
values . push_back ( rnd . RandomString ( 990 ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , values [ i ] ) ) ;
}
}
// put extra key to trigger flush
// put extra key to trigger flush
@ -748,7 +749,7 @@ TEST_P(DBCompactionTestWithParam, CompactionTrigger) {
// generate one more file in level-0, and should trigger level-0 compaction
// generate one more file in level-0, and should trigger level-0 compaction
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int i = 0 ; i < kNumKeysPerFile ; i + + ) {
for ( int i = 0 ; i < kNumKeysPerFile ; i + + ) {
values . push_back ( RandomString ( & rnd , 990 ) ) ;
values . push_back ( rnd . RandomString ( 990 ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , values [ i ] ) ) ;
}
}
// put extra key to trigger flush
// put extra key to trigger flush
@ -867,7 +868,7 @@ TEST_P(DBCompactionTestWithParam, CompactionsGenerateMultipleFiles) {
ASSERT_EQ ( NumTableFilesAtLevel ( 0 , 1 ) , 0 ) ;
ASSERT_EQ ( NumTableFilesAtLevel ( 0 , 1 ) , 0 ) ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int i = 0 ; i < 80 ; i + + ) {
for ( int i = 0 ; i < 80 ; i + + ) {
values . push_back ( RandomString ( & rnd , 100000 ) ) ;
values . push_back ( rnd . RandomString ( 100000 ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , values [ i ] ) ) ;
}
}
@ -1105,7 +1106,7 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveOneFile) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int i = 0 ; i < num_keys ; i + + ) {
for ( int i = 0 ; i < num_keys ; i + + ) {
values . push_back ( RandomString ( & rnd , value_size ) ) ;
values . push_back ( rnd . RandomString ( value_size ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
@ -1177,7 +1178,7 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveNonOverlappingFiles) {
std : : map < int32_t , std : : string > values ;
std : : map < int32_t , std : : string > values ;
for ( size_t i = 0 ; i < ranges . size ( ) ; i + + ) {
for ( size_t i = 0 ; i < ranges . size ( ) ; i + + ) {
for ( int32_t j = ranges [ i ] . first ; j < = ranges [ i ] . second ; j + + ) {
for ( int32_t j = ranges [ i ] . first ; j < = ranges [ i ] . second ; j + + ) {
values [ j ] = RandomString ( & rnd , value_size ) ;
values [ j ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1223,7 +1224,7 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveNonOverlappingFiles) {
} ;
} ;
for ( size_t i = 0 ; i < ranges . size ( ) ; i + + ) {
for ( size_t i = 0 ; i < ranges . size ( ) ; i + + ) {
for ( int32_t j = ranges [ i ] . first ; j < = ranges [ i ] . second ; j + + ) {
for ( int32_t j = ranges [ i ] . first ; j < = ranges [ i ] . second ; j + + ) {
values [ j ] = RandomString ( & rnd , value_size ) ;
values [ j ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1268,14 +1269,14 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveTargetLevel) {
// file 1 [0 => 300]
// file 1 [0 => 300]
for ( int32_t i = 0 ; i < = 300 ; i + + ) {
for ( int32_t i = 0 ; i < = 300 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
// file 2 [600 => 700]
// file 2 [600 => 700]
for ( int32_t i = 600 ; i < = 700 ; i + + ) {
for ( int32_t i = 600 ; i < = 700 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1349,14 +1350,14 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
// file 1 [0 => 100]
// file 1 [0 => 100]
for ( int32_t i = 0 ; i < 100 ; i + + ) {
for ( int32_t i = 0 ; i < 100 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
// file 2 [100 => 300]
// file 2 [100 => 300]
for ( int32_t i = 100 ; i < 300 ; i + + ) {
for ( int32_t i = 100 ; i < 300 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1377,7 +1378,7 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
// file 3 [ 0 => 200]
// file 3 [ 0 => 200]
for ( int32_t i = 0 ; i < 200 ; i + + ) {
for ( int32_t i = 0 ; i < 200 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1409,21 +1410,21 @@ TEST_P(DBCompactionTestWithParam, ManualCompactionPartial) {
TEST_SYNC_POINT ( " DBCompaction::ManualPartial:1 " ) ;
TEST_SYNC_POINT ( " DBCompaction::ManualPartial:1 " ) ;
// file 4 [300 => 400)
// file 4 [300 => 400)
for ( int32_t i = 300 ; i < = 400 ; i + + ) {
for ( int32_t i = 300 ; i < = 400 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
// file 5 [400 => 500)
// file 5 [400 => 500)
for ( int32_t i = 400 ; i < = 500 ; i + + ) {
for ( int32_t i = 400 ; i < = 500 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
// file 6 [500 => 600)
// file 6 [500 => 600)
for ( int32_t i = 500 ; i < = 600 ; i + + ) {
for ( int32_t i = 500 ; i < = 600 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
// Second non-trivial compaction is triggered
// Second non-trivial compaction is triggered
@ -1491,14 +1492,14 @@ TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
// file 1 [0 => 100]
// file 1 [0 => 100]
for ( int32_t i = 0 ; i < 100 ; i + + ) {
for ( int32_t i = 0 ; i < 100 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
// file 2 [100 => 300]
// file 2 [100 => 300]
for ( int32_t i = 100 ; i < 300 ; i + + ) {
for ( int32_t i = 100 ; i < 300 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1517,7 +1518,7 @@ TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
// file 3 [ 0 => 200]
// file 3 [ 0 => 200]
for ( int32_t i = 0 ; i < 200 ; i + + ) {
for ( int32_t i = 0 ; i < 200 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1549,7 +1550,7 @@ TEST_F(DBCompactionTest, DISABLED_ManualPartialFill) {
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
}
}
values [ j ] = RandomString ( & rnd , value_size ) ;
values [ j ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
}
}
}
}
@ -1620,14 +1621,14 @@ TEST_F(DBCompactionTest, DeleteFileRange) {
// file 1 [0 => 100]
// file 1 [0 => 100]
for ( int32_t i = 0 ; i < 100 ; i + + ) {
for ( int32_t i = 0 ; i < 100 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
// file 2 [100 => 300]
// file 2 [100 => 300]
for ( int32_t i = 100 ; i < 300 ; i + + ) {
for ( int32_t i = 100 ; i < 300 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1643,7 +1644,7 @@ TEST_F(DBCompactionTest, DeleteFileRange) {
// file 3 [ 0 => 200]
// file 3 [ 0 => 200]
for ( int32_t i = 0 ; i < 200 ; i + + ) {
for ( int32_t i = 0 ; i < 200 ; i + + ) {
values [ i ] = RandomString ( & rnd , value_size ) ;
values [ i ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1655,7 +1656,7 @@ TEST_F(DBCompactionTest, DeleteFileRange) {
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
}
}
values [ j ] = RandomString ( & rnd , value_size ) ;
values [ j ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
ASSERT_OK ( Put ( Key ( j ) , values [ j ] ) ) ;
}
}
}
}
@ -1742,7 +1743,7 @@ TEST_F(DBCompactionTest, DeleteFilesInRanges) {
for ( auto i = 0 ; i < 10 ; i + + ) {
for ( auto i = 0 ; i < 10 ; i + + ) {
for ( auto j = 0 ; j < 100 ; j + + ) {
for ( auto j = 0 ; j < 100 ; j + + ) {
auto k = i * 100 + j ;
auto k = i * 100 + j ;
values [ k ] = RandomString ( & rnd , value_size ) ;
values [ k ] = rnd . RandomString ( value_size ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
ASSERT_OK ( Put ( Key ( k ) , values [ k ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1874,7 +1875,7 @@ TEST_F(DBCompactionTest, DeleteFileRangeFileEndpointsOverlapBug) {
// would cause `1 -> vals[0]` (an older key) to reappear.
// would cause `1 -> vals[0]` (an older key) to reappear.
std : : string vals [ kNumL0Files ] ;
std : : string vals [ kNumL0Files ] ;
for ( int i = 0 ; i < kNumL0Files ; + + i ) {
for ( int i = 0 ; i < kNumL0Files ; + + i ) {
vals [ i ] = RandomString ( & rnd , kValSize ) ;
vals [ i ] = rnd . RandomString ( kValSize ) ;
Put ( Key ( i ) , vals [ i ] ) ;
Put ( Key ( i ) , vals [ i ] ) ;
Put ( Key ( i + 1 ) , vals [ i ] ) ;
Put ( Key ( i + 1 ) , vals [ i ] ) ;
Flush ( ) ;
Flush ( ) ;
@ -1916,7 +1917,7 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveToLastLevelWithFiles) {
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
// File with keys [ 0 => 99 ]
// File with keys [ 0 => 99 ]
for ( int i = 0 ; i < 100 ; i + + ) {
for ( int i = 0 ; i < 100 ; i + + ) {
values . push_back ( RandomString ( & rnd , value_size ) ) ;
values . push_back ( rnd . RandomString ( value_size ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -1934,7 +1935,7 @@ TEST_P(DBCompactionTestWithParam, TrivialMoveToLastLevelWithFiles) {
// File with keys [ 100 => 199 ]
// File with keys [ 100 => 199 ]
for ( int i = 100 ; i < 200 ; i + + ) {
for ( int i = 100 ; i < 200 ; i + + ) {
values . push_back ( RandomString ( & rnd , value_size ) ) ;
values . push_back ( rnd . RandomString ( value_size ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( Key ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -2329,7 +2330,7 @@ TEST_P(DBCompactionTestWithParam, ConvertCompactionStyle) {
for ( int i = 0 ; i < = max_key_level_insert ; i + + ) {
for ( int i = 0 ; i < = max_key_level_insert ; i + + ) {
// each value is 10K
// each value is 10K
ASSERT_OK ( Put ( 1 , Key ( i ) , RandomString ( & rnd , 10000 ) ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , rnd . RandomString ( 10000 ) ) ) ;
}
}
ASSERT_OK ( Flush ( 1 ) ) ;
ASSERT_OK ( Flush ( 1 ) ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
@ -2387,7 +2388,7 @@ TEST_P(DBCompactionTestWithParam, ConvertCompactionStyle) {
ReopenWithColumnFamilies ( { " default " , " pikachu " } , options ) ;
ReopenWithColumnFamilies ( { " default " , " pikachu " } , options ) ;
for ( int i = max_key_level_insert / 2 ; i < = max_key_universal_insert ; i + + ) {
for ( int i = max_key_level_insert / 2 ; i < = max_key_universal_insert ; i + + ) {
ASSERT_OK ( Put ( 1 , Key ( i ) , RandomString ( & rnd , 10000 ) ) ) ;
ASSERT_OK ( Put ( 1 , Key ( i ) , rnd . RandomString ( 10000 ) ) ) ;
}
}
dbfull ( ) - > Flush ( FlushOptions ( ) ) ;
dbfull ( ) - > Flush ( FlushOptions ( ) ) ;
ASSERT_OK ( Flush ( 1 ) ) ;
ASSERT_OK ( Flush ( 1 ) ) ;
@ -2682,7 +2683,7 @@ TEST_P(DBCompactionTestWithParam, DISABLED_CompactFilesOnLevelCompaction) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int key = 64 * kEntriesPerBuffer ; key > = 0 ; - - key ) {
for ( int key = 64 * kEntriesPerBuffer ; key > = 0 ; - - key ) {
ASSERT_OK ( Put ( 1 , ToString ( key ) , RandomString ( & rnd , kTestValueSize ) ) ) ;
ASSERT_OK ( Put ( 1 , ToString ( key ) , rnd . RandomString ( kTestValueSize ) ) ) ;
}
}
dbfull ( ) - > TEST_WaitForFlushMemTable ( handles_ [ 1 ] ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( handles_ [ 1 ] ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
@ -2758,8 +2759,8 @@ TEST_P(DBCompactionTestWithParam, PartialCompactionFailure) {
std : : vector < std : : string > keys ;
std : : vector < std : : string > keys ;
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
for ( int k = 0 ; k < kNumInsertedKeys ; + + k ) {
for ( int k = 0 ; k < kNumInsertedKeys ; + + k ) {
keys . emplace_back ( RandomString ( & rnd , kKeySize ) ) ;
keys . emplace_back ( rnd . RandomString ( kKeySize ) ) ;
values . emplace_back ( RandomString ( & rnd , kKvSize - kKeySize ) ) ;
values . emplace_back ( rnd . RandomString ( kKvSize - kKeySize ) ) ;
ASSERT_OK ( Put ( Slice ( keys [ k ] ) , Slice ( values [ k ] ) ) ) ;
ASSERT_OK ( Put ( Slice ( keys [ k ] ) , Slice ( values [ k ] ) ) ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
dbfull ( ) - > TEST_WaitForFlushMemTable ( ) ;
}
}
@ -2825,7 +2826,7 @@ TEST_P(DBCompactionTestWithParam, DeleteMovedFileAfterCompaction) {
for ( int i = 0 ; i < 2 ; + + i ) {
for ( int i = 0 ; i < 2 ; + + i ) {
// Create 1MB sst file
// Create 1MB sst file
for ( int j = 0 ; j < 100 ; + + j ) {
for ( int j = 0 ; j < 100 ; + + j ) {
ASSERT_OK ( Put ( Key ( i * 50 + j ) , RandomString ( & rnd , 10 * 1024 ) ) ) ;
ASSERT_OK ( Put ( Key ( i * 50 + j ) , rnd . RandomString ( 10 * 1024 ) ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
}
}
@ -2860,7 +2861,7 @@ TEST_P(DBCompactionTestWithParam, DeleteMovedFileAfterCompaction) {
for ( int i = 0 ; i < 2 ; + + i ) {
for ( int i = 0 ; i < 2 ; + + i ) {
// Create 1MB sst file
// Create 1MB sst file
for ( int j = 0 ; j < 100 ; + + j ) {
for ( int j = 0 ; j < 100 ; + + j ) {
ASSERT_OK ( Put ( Key ( i * 50 + j + 100 ) , RandomString ( & rnd , 10 * 1024 ) ) ) ;
ASSERT_OK ( Put ( Key ( i * 50 + j + 100 ) , rnd . RandomString ( 10 * 1024 ) ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
}
}
@ -3118,7 +3119,7 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
std : : vector < std : : string > values ;
std : : vector < std : : string > values ;
// File with keys [ 0 => 99 ]
// File with keys [ 0 => 99 ]
for ( int i = 0 ; i < 100 ; i + + ) {
for ( int i = 0 ; i < 100 ; i + + ) {
values . push_back ( RandomString ( & rnd , value_size ) ) ;
values . push_back ( rnd . RandomString ( value_size ) ) ;
ASSERT_OK ( Put ( ShortKey ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( ShortKey ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -3135,7 +3136,7 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
// File with keys [ 100 => 199 ]
// File with keys [ 100 => 199 ]
for ( int i = 100 ; i < 200 ; i + + ) {
for ( int i = 100 ; i < 200 ; i + + ) {
values . push_back ( RandomString ( & rnd , value_size ) ) ;
values . push_back ( rnd . RandomString ( value_size ) ) ;
ASSERT_OK ( Put ( ShortKey ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( ShortKey ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -3153,7 +3154,7 @@ TEST_P(DBCompactionTestWithParam, ForceBottommostLevelCompaction) {
// File with keys [ 200 => 299 ]
// File with keys [ 200 => 299 ]
for ( int i = 200 ; i < 300 ; i + + ) {
for ( int i = 200 ; i < 300 ; i + + ) {
values . push_back ( RandomString ( & rnd , value_size ) ) ;
values . push_back ( rnd . RandomString ( value_size ) ) ;
ASSERT_OK ( Put ( ShortKey ( i ) , values [ i ] ) ) ;
ASSERT_OK ( Put ( ShortKey ( i ) , values [ i ] ) ) ;
}
}
ASSERT_OK ( Flush ( ) ) ;
ASSERT_OK ( Flush ( ) ) ;
@ -3197,7 +3198,7 @@ TEST_P(DBCompactionTestWithParam, IntraL0Compaction) {
const size_t kValueSize = 1 < < 20 ;
const size_t kValueSize = 1 < < 20 ;
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
std : : string value ( RandomString ( & rnd , kValueSize ) ) ;
std : : string value ( rnd . RandomString ( kValueSize ) ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > LoadDependency (
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > LoadDependency (
{ { " LevelCompactionPicker::PickCompactionBySize:0 " ,
{ { " LevelCompactionPicker::PickCompactionBySize:0 " ,
@ -3261,7 +3262,7 @@ TEST_P(DBCompactionTestWithParam, IntraL0CompactionDoesNotObsoleteDeletions) {
const size_t kValueSize = 1 < < 20 ;
const size_t kValueSize = 1 < < 20 ;
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
std : : string value ( RandomString ( & rnd , kValueSize ) ) ;
std : : string value ( rnd . RandomString ( kValueSize ) ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > LoadDependency (
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > LoadDependency (
{ { " LevelCompactionPicker::PickCompactionBySize:0 " ,
{ { " LevelCompactionPicker::PickCompactionBySize:0 " ,
@ -3480,7 +3481,7 @@ TEST_F(DBCompactionTest, CompactBottomLevelFilesWithDeletions) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( Key ( i * kNumKeysPerFile + j ) , RandomString ( & rnd , kValueSize ) ) ) ;
Put ( Key ( i * kNumKeysPerFile + j ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
if ( i = = kNumLevelFiles - 1 ) {
if ( i = = kNumLevelFiles - 1 ) {
snapshot = db_ - > GetSnapshot ( ) ;
snapshot = db_ - > GetSnapshot ( ) ;
@ -3552,7 +3553,7 @@ TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( Key ( i * kNumKeysPerFile + j ) , RandomString ( & rnd , kValueSize ) ) ) ;
Put ( Key ( i * kNumKeysPerFile + j ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -3598,7 +3599,7 @@ TEST_F(DBCompactionTest, LevelCompactExpiredTtlFiles) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( Key ( i * kNumKeysPerFile + j ) , RandomString ( & rnd , kValueSize ) ) ) ;
Put ( Key ( i * kNumKeysPerFile + j ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -3693,7 +3694,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
// Add two L6 files with key ranges: [1 .. 100], [101 .. 200].
// Add two L6 files with key ranges: [1 .. 100], [101 .. 200].
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int i = 1 ; i < = 100 ; + + i ) {
for ( int i = 1 ; i < = 100 ; + + i ) {
ASSERT_OK ( Put ( Key ( i ) , RandomString ( & rnd , kValueSize ) ) ) ;
ASSERT_OK ( Put ( Key ( i ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
// Get the first file's creation time. This will be the oldest file in the
// Get the first file's creation time. This will be the oldest file in the
@ -3706,7 +3707,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
// Add 1 hour and do another flush.
// Add 1 hour and do another flush.
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
for ( int i = 101 ; i < = 200 ; + + i ) {
for ( int i = 101 ; i < = 200 ; + + i ) {
ASSERT_OK ( Put ( Key ( i ) , RandomString ( & rnd , kValueSize ) ) ) ;
ASSERT_OK ( Put ( Key ( i ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
MoveFilesToLevel ( 6 ) ;
MoveFilesToLevel ( 6 ) ;
@ -3715,12 +3716,12 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
// Add two L4 files with key ranges: [1 .. 50], [51 .. 150].
// Add two L4 files with key ranges: [1 .. 50], [51 .. 150].
for ( int i = 1 ; i < = 50 ; + + i ) {
for ( int i = 1 ; i < = 50 ; + + i ) {
ASSERT_OK ( Put ( Key ( i ) , RandomString ( & rnd , kValueSize ) ) ) ;
ASSERT_OK ( Put ( Key ( i ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
for ( int i = 51 ; i < = 150 ; + + i ) {
for ( int i = 51 ; i < = 150 ; + + i ) {
ASSERT_OK ( Put ( Key ( i ) , RandomString ( & rnd , kValueSize ) ) ) ;
ASSERT_OK ( Put ( Key ( i ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
MoveFilesToLevel ( 4 ) ;
MoveFilesToLevel ( 4 ) ;
@ -3729,7 +3730,7 @@ TEST_F(DBCompactionTest, LevelTtlCascadingCompactions) {
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
env_ - > addon_time_ . fetch_add ( 1 * 60 * 60 ) ;
// Add one L1 file with key range: [26, 75].
// Add one L1 file with key range: [26, 75].
for ( int i = 26 ; i < = 75 ; + + i ) {
for ( int i = 26 ; i < = 75 ; + + i ) {
ASSERT_OK ( Put ( Key ( i ) , RandomString ( & rnd , kValueSize ) ) ) ;
ASSERT_OK ( Put ( Key ( i ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
@ -3840,8 +3841,8 @@ TEST_F(DBCompactionTest, LevelPeriodicCompaction) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
ASSERT_OK ( Put ( Key ( i * kNumKeysPerFile + j ) ,
ASSERT_OK (
RandomString ( & rnd , kValueSize ) ) ) ;
Put ( Key ( i * kNumKeysPerFile + j ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -3935,7 +3936,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithOldDB) {
for ( int i = 0 ; i < kNumFiles ; + + i ) {
for ( int i = 0 ; i < kNumFiles ; + + i ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( Key ( i * kNumKeysPerFile + j ) , RandomString ( & rnd , kValueSize ) ) ) ;
Put ( Key ( i * kNumKeysPerFile + j ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
// Move the first two files to L2.
// Move the first two files to L2.
@ -3998,7 +3999,7 @@ TEST_F(DBCompactionTest, LevelPeriodicAndTtlCompaction) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( Key ( i * kNumKeysPerFile + j ) , RandomString ( & rnd , kValueSize ) ) ) ;
Put ( Key ( i * kNumKeysPerFile + j ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -4109,7 +4110,7 @@ TEST_F(DBCompactionTest, LevelPeriodicCompactionWithCompactionFilters) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int i = 0 ; i < kNumLevelFiles ; + + i ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j < kNumKeysPerFile ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( Key ( i * kNumKeysPerFile + j ) , RandomString ( & rnd , kValueSize ) ) ) ;
Put ( Key ( i * kNumKeysPerFile + j ) , rnd . RandomString ( kValueSize ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -4169,7 +4170,7 @@ TEST_F(DBCompactionTest, CompactRangeDelayedByL0FileCount) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int j = 0 ; j < kNumL0FilesLimit - 1 ; + + j ) {
for ( int j = 0 ; j < kNumL0FilesLimit - 1 ; + + j ) {
for ( int k = 0 ; k < 2 ; + + k ) {
for ( int k = 0 ; k < 2 ; + + k ) {
ASSERT_OK ( Put ( Key ( k ) , RandomString ( & rnd , 1024 ) ) ) ;
ASSERT_OK ( Put ( Key ( k ) , rnd . RandomString ( 1024 ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -4223,7 +4224,7 @@ TEST_F(DBCompactionTest, CompactRangeDelayedByImmMemTableCount) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int j = 0 ; j < kNumImmMemTableLimit - 1 ; + + j ) {
for ( int j = 0 ; j < kNumImmMemTableLimit - 1 ; + + j ) {
ASSERT_OK ( Put ( Key ( 0 ) , RandomString ( & rnd , 1024 ) ) ) ;
ASSERT_OK ( Put ( Key ( 0 ) , rnd . RandomString ( 1024 ) ) ) ;
FlushOptions flush_opts ;
FlushOptions flush_opts ;
flush_opts . wait = false ;
flush_opts . wait = false ;
flush_opts . allow_write_stall = true ;
flush_opts . allow_write_stall = true ;
@ -4271,7 +4272,7 @@ TEST_F(DBCompactionTest, CompactRangeShutdownWhileDelayed) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int j = 0 ; j < kNumL0FilesLimit - 1 ; + + j ) {
for ( int j = 0 ; j < kNumL0FilesLimit - 1 ; + + j ) {
for ( int k = 0 ; k < 2 ; + + k ) {
for ( int k = 0 ; k < 2 ; + + k ) {
ASSERT_OK ( Put ( 1 , Key ( k ) , RandomString ( & rnd , 1024 ) ) ) ;
ASSERT_OK ( Put ( 1 , Key ( k ) , rnd . RandomString ( 1024 ) ) ) ;
}
}
Flush ( 1 ) ;
Flush ( 1 ) ;
}
}
@ -4331,7 +4332,7 @@ TEST_F(DBCompactionTest, CompactRangeSkipFlushAfterDelay) {
flush_opts . allow_write_stall = true ;
flush_opts . allow_write_stall = true ;
for ( int i = 0 ; i < kNumL0FilesLimit - 1 ; + + i ) {
for ( int i = 0 ; i < kNumL0FilesLimit - 1 ; + + i ) {
for ( int j = 0 ; j < 2 ; + + j ) {
for ( int j = 0 ; j < 2 ; + + j ) {
ASSERT_OK ( Put ( Key ( j ) , RandomString ( & rnd , 1024 ) ) ) ;
ASSERT_OK ( Put ( Key ( j ) , rnd . RandomString ( 1024 ) ) ) ;
}
}
dbfull ( ) - > Flush ( flush_opts ) ;
dbfull ( ) - > Flush ( flush_opts ) ;
}
}
@ -4342,9 +4343,9 @@ TEST_F(DBCompactionTest, CompactRangeSkipFlushAfterDelay) {
} ) ;
} ) ;
TEST_SYNC_POINT ( " DBCompactionTest::CompactRangeSkipFlushAfterDelay:PreFlush " ) ;
TEST_SYNC_POINT ( " DBCompactionTest::CompactRangeSkipFlushAfterDelay:PreFlush " ) ;
Put ( ToString ( 0 ) , RandomString ( & rnd , 1024 ) ) ;
Put ( ToString ( 0 ) , rnd . RandomString ( 1024 ) ) ;
dbfull ( ) - > Flush ( flush_opts ) ;
dbfull ( ) - > Flush ( flush_opts ) ;
Put ( ToString ( 0 ) , RandomString ( & rnd , 1024 ) ) ;
Put ( ToString ( 0 ) , rnd . RandomString ( 1024 ) ) ;
TEST_SYNC_POINT ( " DBCompactionTest::CompactRangeSkipFlushAfterDelay:PostFlush " ) ;
TEST_SYNC_POINT ( " DBCompactionTest::CompactRangeSkipFlushAfterDelay:PostFlush " ) ;
manual_compaction_thread . join ( ) ;
manual_compaction_thread . join ( ) ;
@ -4784,7 +4785,7 @@ TEST_P(CompactionPriTest, Test) {
RandomShuffle ( std : : begin ( keys ) , std : : end ( keys ) , rnd . Next ( ) ) ;
RandomShuffle ( std : : begin ( keys ) , std : : end ( keys ) , rnd . Next ( ) ) ;
for ( int i = 0 ; i < kNKeys ; i + + ) {
for ( int i = 0 ; i < kNKeys ; i + + ) {
ASSERT_OK ( Put ( Key ( keys [ i ] ) , RandomString ( & rnd , 102 ) ) ) ;
ASSERT_OK ( Put ( Key ( keys [ i ] ) , rnd . RandomString ( 102 ) ) ) ;
}
}
dbfull ( ) - > TEST_WaitForCompact ( ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
@ -4826,7 +4827,7 @@ TEST_F(DBCompactionTest, PartialManualCompaction) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( auto i = 0 ; i < 8 ; + + i ) {
for ( auto i = 0 ; i < 8 ; + + i ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
Merge ( " foo " , RandomString ( & rnd , 1024 ) ) ;
Merge ( " foo " , rnd . RandomString ( 1024 ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -4858,8 +4859,8 @@ TEST_F(DBCompactionTest, ManualCompactionFailsInReadOnlyMode) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int i = 0 ; i < kNumL0Files ; + + i ) {
for ( int i = 0 ; i < kNumL0Files ; + + i ) {
// Make sure files are overlapping in key-range to prevent trivial move.
// Make sure files are overlapping in key-range to prevent trivial move.
Put ( " key1 " , RandomString ( & rnd , 1024 ) ) ;
Put ( " key1 " , rnd . RandomString ( 1024 ) ) ;
Put ( " key2 " , RandomString ( & rnd , 1024 ) ) ;
Put ( " key2 " , rnd . RandomString ( 1024 ) ) ;
Flush ( ) ;
Flush ( ) ;
}
}
ASSERT_EQ ( kNumL0Files , NumTableFilesAtLevel ( 0 ) ) ;
ASSERT_EQ ( kNumL0Files , NumTableFilesAtLevel ( 0 ) ) ;
@ -4868,7 +4869,7 @@ TEST_F(DBCompactionTest, ManualCompactionFailsInReadOnlyMode) {
mock_env - > SetFilesystemActive ( false ) ;
mock_env - > SetFilesystemActive ( false ) ;
// Make sure this is outside `CompactRange`'s range so that it doesn't fail
// Make sure this is outside `CompactRange`'s range so that it doesn't fail
// early trying to flush memtable.
// early trying to flush memtable.
ASSERT_NOK ( Put ( " key3 " , RandomString ( & rnd , 1024 ) ) ) ;
ASSERT_NOK ( Put ( " key3 " , rnd . RandomString ( 1024 ) ) ) ;
// In the bug scenario, the first manual compaction would fail and forget to
// In the bug scenario, the first manual compaction would fail and forget to
// unregister itself, causing the second one to hang forever due to conflict
// unregister itself, causing the second one to hang forever due to conflict
@ -4907,7 +4908,7 @@ TEST_F(DBCompactionTest, ManualCompactionBottomLevelOptimized) {
for ( auto i = 0 ; i < 8 ; + + i ) {
for ( auto i = 0 ; i < 8 ; + + i ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( " foo " + std : : to_string ( i * 10 + j ) , RandomString ( & rnd , 1024 ) ) ) ;
Put ( " foo " + std : : to_string ( i * 10 + j ) , rnd . RandomString ( 1024 ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -4917,7 +4918,7 @@ TEST_F(DBCompactionTest, ManualCompactionBottomLevelOptimized) {
for ( auto i = 0 ; i < 8 ; + + i ) {
for ( auto i = 0 ; i < 8 ; + + i ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( " bar " + std : : to_string ( i * 10 + j ) , RandomString ( & rnd , 1024 ) ) ) ;
Put ( " bar " + std : : to_string ( i * 10 + j ) , rnd . RandomString ( 1024 ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -4951,7 +4952,7 @@ TEST_F(DBCompactionTest, CompactionDuringShutdown) {
for ( auto i = 0 ; i < 2 ; + + i ) {
for ( auto i = 0 ; i < 2 ; + + i ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
for ( auto j = 0 ; j < 10 ; + + j ) {
ASSERT_OK (
ASSERT_OK (
Put ( " foo " + std : : to_string ( i * 10 + j ) , RandomString ( & rnd , 1024 ) ) ) ;
Put ( " foo " + std : : to_string ( i * 10 + j ) , rnd . RandomString ( 1024 ) ) ) ;
}
}
Flush ( ) ;
Flush ( ) ;
}
}
@ -4974,7 +4975,7 @@ TEST_P(DBCompactionTestWithParam, FixFileIngestionCompactionDeadlock) {
// Generate an external SST file containing a single key, i.e. 99
// Generate an external SST file containing a single key, i.e. 99
std : : string sst_files_dir = dbname_ + " /sst_files/ " ;
std : : string sst_files_dir = dbname_ + " /sst_files/ " ;
test : : DestroyDir ( env_ , sst_files_dir ) ;
DestroyDir ( env_ , sst_files_dir ) ;
ASSERT_OK ( env_ - > CreateDir ( sst_files_dir ) ) ;
ASSERT_OK ( env_ - > CreateDir ( sst_files_dir ) ) ;
SstFileWriter sst_writer ( EnvOptions ( ) , options ) ;
SstFileWriter sst_writer ( EnvOptions ( ) , options ) ;
const std : : string sst_file_path = sst_files_dir + " test.sst " ;
const std : : string sst_file_path = sst_files_dir + " test.sst " ;
@ -5001,7 +5002,7 @@ TEST_P(DBCompactionTestWithParam, FixFileIngestionCompactionDeadlock) {
// Generate level0_stop_writes_trigger L0 files to trigger write stop
// Generate level0_stop_writes_trigger L0 files to trigger write stop
for ( int i = 0 ; i ! = options . level0_file_num_compaction_trigger ; + + i ) {
for ( int i = 0 ; i ! = options . level0_file_num_compaction_trigger ; + + i ) {
for ( int j = 0 ; j ! = kNumKeysPerFile ; + + j ) {
for ( int j = 0 ; j ! = kNumKeysPerFile ; + + j ) {
ASSERT_OK ( Put ( Key ( j ) , RandomString ( & rnd , 990 ) ) ) ;
ASSERT_OK ( Put ( Key ( j ) , rnd . RandomString ( 990 ) ) ) ;
}
}
if ( 0 = = i ) {
if ( 0 = = i ) {
// When we reach here, the memtables have kNumKeysPerFile keys. Note that
// When we reach here, the memtables have kNumKeysPerFile keys. Note that
@ -5093,7 +5094,7 @@ TEST_F(DBCompactionTest, ConsistencyFailTest2) {
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > EnableProcessing ( ) ;
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
std : : string value = RandomString ( & rnd , 1000 ) ;
std : : string value = rnd . RandomString ( 1000 ) ;
ASSERT_OK ( Put ( " foo1 " , value ) ) ;
ASSERT_OK ( Put ( " foo1 " , value ) ) ;
ASSERT_OK ( Put ( " z " , " " ) ) ;
ASSERT_OK ( Put ( " z " , " " ) ) ;
@ -5140,7 +5141,7 @@ TEST_P(DBCompactionTestWithParam,
const size_t kValueSize = 1 < < 20 ;
const size_t kValueSize = 1 < < 20 ;
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
std : : atomic < int > pick_intra_l0_count ( 0 ) ;
std : : atomic < int > pick_intra_l0_count ( 0 ) ;
std : : string value ( RandomString ( & rnd , kValueSize ) ) ;
std : : string value ( rnd . RandomString ( kValueSize ) ) ;
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > LoadDependency (
ROCKSDB_NAMESPACE : : SyncPoint : : GetInstance ( ) - > LoadDependency (
{ { " DBCompactionTestWithParam::FlushAfterIntraL0:1 " ,
{ { " DBCompactionTestWithParam::FlushAfterIntraL0:1 " ,
@ -5207,8 +5208,8 @@ TEST_P(DBCompactionTestWithParam,
const size_t kValueSize = 1 < < 20 ;
const size_t kValueSize = 1 < < 20 ;
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
std : : string value ( RandomString ( & rnd , kValueSize ) ) ;
std : : string value ( rnd . RandomString ( kValueSize ) ) ;
std : : string value2 ( RandomString ( & rnd , kValueSize ) ) ;
std : : string value2 ( rnd . RandomString ( kValueSize ) ) ;
std : : string bigvalue = value + value ;
std : : string bigvalue = value + value ;
// prevents trivial move
// prevents trivial move