@ -23,37 +23,44 @@ class DBRangeDelTest : public DBTestBase {
}
}
} ;
} ;
const int kRangeDelSkipConfigs =
// Plain tables do not support range deletions.
DBRangeDelTest : : kSkipPlainTable |
// MmapReads disables the iterator pinning that RangeDelAggregator requires.
DBRangeDelTest : : kSkipMmapReads ;
// PlainTableFactory and NumTableFilesAtLevel() are not supported in
// PlainTableFactory and NumTableFilesAtLevel() are not supported in
// ROCKSDB_LITE
// ROCKSDB_LITE
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
TEST_F ( DBRangeDelTest , NonBlockBasedTableNotSupported ) {
TEST_F ( DBRangeDelTest , NonBlockBasedTableNotSupported ) {
if ( ! IsMemoryMappedAccessSupported ( ) ) {
// TODO: figure out why MmapReads trips the iterator pinning assertion in
return ;
// RangeDelAggregator. Ideally it would be supported; otherwise it should at
}
// least be explicitly unsupported.
Options opts = CurrentOptions ( ) ;
for ( auto config : { kPlainTableAllBytesPrefix , /* kWalDirAndMmapReads */ } ) {
opts . table_factory . reset ( new PlainTableFactory ( ) ) ;
option_config_ = config ;
opts . prefix_extractor . reset ( NewNoopTransform ( ) ) ;
DestroyAndReopen ( CurrentOptions ( ) ) ;
opts . allow_mmap_reads = true ;
opts . max_sequential_skip_in_iterations = 999999 ;
Reopen ( opts ) ;
ASSERT_TRUE (
ASSERT_TRUE (
db_ - > DeleteRange ( WriteOptions ( ) , db_ - > DefaultColumnFamily ( ) , " dr1 " , " dr1 " )
db_ - > DeleteRange ( WriteOptions ( ) , db_ - > DefaultColumnFamily ( ) , " dr1 " , " dr1 " )
. IsNotSupported ( ) ) ;
. IsNotSupported ( ) ) ;
}
}
}
TEST_F ( DBRangeDelTest , FlushOutputHasOnlyRangeTombstones ) {
TEST_F ( DBRangeDelTest , FlushOutputHasOnlyRangeTombstones ) {
do {
DestroyAndReopen ( CurrentOptions ( ) ) ;
ASSERT_OK ( db_ - > DeleteRange ( WriteOptions ( ) , db_ - > DefaultColumnFamily ( ) , " dr1 " ,
ASSERT_OK ( db_ - > DeleteRange ( WriteOptions ( ) , db_ - > DefaultColumnFamily ( ) , " dr1 " ,
" dr2 " ) ) ;
" dr2 " ) ) ;
ASSERT_OK ( db_ - > Flush ( FlushOptions ( ) ) ) ;
ASSERT_OK ( db_ - > Flush ( FlushOptions ( ) ) ) ;
ASSERT_EQ ( 1 , NumTableFilesAtLevel ( 0 ) ) ;
ASSERT_EQ ( 1 , NumTableFilesAtLevel ( 0 ) ) ;
} while ( ChangeOptions ( kRangeDelSkipConfigs ) ) ;
}
}
TEST_F ( DBRangeDelTest , CompactionOutputHasOnlyRangeTombstone ) {
TEST_F ( DBRangeDelTest , CompactionOutputHasOnlyRangeTombstone ) {
do {
Options opts = CurrentOptions ( ) ;
Options opts = CurrentOptions ( ) ;
opts . disable_auto_compactions = true ;
opts . disable_auto_compactions = true ;
opts . statistics = CreateDBStatistics ( ) ;
opts . statistics = CreateDBStatistics ( ) ;
Reopen ( opts ) ;
DestroyAnd Reopen( opts ) ;
// snapshot protects range tombstone from dropping due to becoming obsolete.
// snapshot protects range tombstone from dropping due to becoming obsolete.
const Snapshot * snapshot = db_ - > GetSnapshot ( ) ;
const Snapshot * snapshot = db_ - > GetSnapshot ( ) ;
@ -68,6 +75,11 @@ TEST_F(DBRangeDelTest, CompactionOutputHasOnlyRangeTombstone) {
ASSERT_EQ ( 1 , NumTableFilesAtLevel ( 1 ) ) ;
ASSERT_EQ ( 1 , NumTableFilesAtLevel ( 1 ) ) ;
ASSERT_EQ ( 0 , TestGetTickerCount ( opts , COMPACTION_RANGE_DEL_DROP_OBSOLETE ) ) ;
ASSERT_EQ ( 0 , TestGetTickerCount ( opts , COMPACTION_RANGE_DEL_DROP_OBSOLETE ) ) ;
db_ - > ReleaseSnapshot ( snapshot ) ;
db_ - > ReleaseSnapshot ( snapshot ) ;
// Skip cuckoo memtables, which do not support snapshots. Skip non-leveled
// compactions as the above assertions about the number of files in a level
// do not hold true.
} while ( ChangeOptions ( kRangeDelSkipConfigs | kSkipHashCuckoo |
kSkipUniversalCompaction | kSkipFIFOCompaction ) ) ;
}
}
TEST_F ( DBRangeDelTest , CompactionOutputFilesExactlyFilled ) {
TEST_F ( DBRangeDelTest , CompactionOutputFilesExactlyFilled ) {
@ -590,6 +602,8 @@ TEST_F(DBRangeDelTest, TableEvictedDuringScan) {
}
}
TEST_F ( DBRangeDelTest , GetCoveredKeyFromMutableMemtable ) {
TEST_F ( DBRangeDelTest , GetCoveredKeyFromMutableMemtable ) {
do {
DestroyAndReopen ( CurrentOptions ( ) ) ;
db_ - > Put ( WriteOptions ( ) , " key " , " val " ) ;
db_ - > Put ( WriteOptions ( ) , " key " , " val " ) ;
ASSERT_OK (
ASSERT_OK (
db_ - > DeleteRange ( WriteOptions ( ) , db_ - > DefaultColumnFamily ( ) , " a " , " z " ) ) ;
db_ - > DeleteRange ( WriteOptions ( ) , db_ - > DefaultColumnFamily ( ) , " a " , " z " ) ) ;
@ -597,9 +611,11 @@ TEST_F(DBRangeDelTest, GetCoveredKeyFromMutableMemtable) {
ReadOptions read_opts ;
ReadOptions read_opts ;
std : : string value ;
std : : string value ;
ASSERT_TRUE ( db_ - > Get ( read_opts , " key " , & value ) . IsNotFound ( ) ) ;
ASSERT_TRUE ( db_ - > Get ( read_opts , " key " , & value ) . IsNotFound ( ) ) ;
} while ( ChangeOptions ( kRangeDelSkipConfigs ) ) ;
}
}
TEST_F ( DBRangeDelTest , GetCoveredKeyFromImmutableMemtable ) {
TEST_F ( DBRangeDelTest , GetCoveredKeyFromImmutableMemtable ) {
do {
Options opts = CurrentOptions ( ) ;
Options opts = CurrentOptions ( ) ;
opts . max_write_buffer_number = 3 ;
opts . max_write_buffer_number = 3 ;
opts . min_write_buffer_number_to_merge = 2 ;
opts . min_write_buffer_number_to_merge = 2 ;
@ -608,7 +624,7 @@ TEST_F(DBRangeDelTest, GetCoveredKeyFromImmutableMemtable) {
// prevented by the above options) upon inserting an element that would
// prevented by the above options) upon inserting an element that would
// overflow the memtable.
// overflow the memtable.
opts . memtable_factory . reset ( new SpecialSkipListFactory ( 1 ) ) ;
opts . memtable_factory . reset ( new SpecialSkipListFactory ( 1 ) ) ;
Reopen ( opts ) ;
DestroyAnd Reopen( opts ) ;
db_ - > Put ( WriteOptions ( ) , " key " , " val " ) ;
db_ - > Put ( WriteOptions ( ) , " key " , " val " ) ;
ASSERT_OK (
ASSERT_OK (
@ -618,9 +634,12 @@ TEST_F(DBRangeDelTest, GetCoveredKeyFromImmutableMemtable) {
ReadOptions read_opts ;
ReadOptions read_opts ;
std : : string value ;
std : : string value ;
ASSERT_TRUE ( db_ - > Get ( read_opts , " key " , & value ) . IsNotFound ( ) ) ;
ASSERT_TRUE ( db_ - > Get ( read_opts , " key " , & value ) . IsNotFound ( ) ) ;
} while ( ChangeOptions ( kRangeDelSkipConfigs ) ) ;
}
}
TEST_F ( DBRangeDelTest , GetCoveredKeyFromSst ) {
TEST_F ( DBRangeDelTest , GetCoveredKeyFromSst ) {
do {
DestroyAndReopen ( CurrentOptions ( ) ) ;
db_ - > Put ( WriteOptions ( ) , " key " , " val " ) ;
db_ - > Put ( WriteOptions ( ) , " key " , " val " ) ;
// snapshot prevents key from being deleted during flush
// snapshot prevents key from being deleted during flush
const Snapshot * snapshot = db_ - > GetSnapshot ( ) ;
const Snapshot * snapshot = db_ - > GetSnapshot ( ) ;
@ -632,6 +651,8 @@ TEST_F(DBRangeDelTest, GetCoveredKeyFromSst) {
std : : string value ;
std : : string value ;
ASSERT_TRUE ( db_ - > Get ( read_opts , " key " , & value ) . IsNotFound ( ) ) ;
ASSERT_TRUE ( db_ - > Get ( read_opts , " key " , & value ) . IsNotFound ( ) ) ;
db_ - > ReleaseSnapshot ( snapshot ) ;
db_ - > ReleaseSnapshot ( snapshot ) ;
// Cuckoo memtables do not support snapshots.
} while ( ChangeOptions ( kRangeDelSkipConfigs | kSkipHashCuckoo ) ) ;
}
}
TEST_F ( DBRangeDelTest , GetCoveredMergeOperandFromMemtable ) {
TEST_F ( DBRangeDelTest , GetCoveredMergeOperandFromMemtable ) {