rocksdb icon indicating copy to clipboard operation
rocksdb copied to clipboard

The tombstone is not destroyed by the compact range

Open yangzhijia opened this issue 7 years ago • 3 comments

Rocksdb version: 5.10.4

question

In our environment, we use delete range to delete the data, and then we call the compact range method for destroy the tombstone. We found that there were many tombstones left at the bottommost level.

Actual behavior

As we know the key covered by a tombstone may still be visible to a snapshot. We dump the manifest and found something unusual. AddFile: 4 4792924 34157801 '016B12F80100FF9BF802D99DF802D99D80BF56A7C188C697B6126B437851706D536234344763365279386577364A70573867564B71686E7737616F41676E385532436A52707250303551646C32754F3D62466B4F76783954306F41437742306B75717A6F626B61657A646C6E4C783774576E643D42695864614D6562314B69527938466C39523D6D3172367A55374E72414E3770797270474471314B3168305348754E636D53584E6A6546427258517272557763532D47726F4B6E47645445564A6D536A30336E62396633694D42574C7A6C326F645546666B433353596B68686D5651624D564F6A35666741446C5361497656586B554D6C68786672513035777562347A656E484231614F6A3270334A424437436B6544426100FF0188000174786E2D65666662633734362D663332332D313165382D383237662D3264316664303064383037330000000000000000' seq:46775404473, type:0 .. '016B12F8016E41F802E707F802E707F816CDE41236666330643634642D656335652D343764612D393232382D6162333862633733643864625F3239335F305F323900FF0188000174786E2D32346635663230642D656162382D313165382D613163652D3366656464646364326636320000000000000000' seq:72057594037927935, type:15

The tombstone's seq is the largest one of all sequence number, and the tombstone should never be deleted, according to the following code if (bottommost_level_ && tombstone.seq_ <= earliest_snapshot) {……}

Here is the manifest

yangzhijia avatar Dec 12 '18 11:12 yangzhijia

The range tombstone doesn't actually have a sequence number of kMaxSequenceNumber. That's a fake key we use to indicate that a range tombstone extends past the end of the file. However, this still means that you have range tombstones at the bottommost level. Do you have any snapshots created before the range tombstones that are preventing the tombstones from being dropped?

abhimadan avatar Dec 12 '18 18:12 abhimadan

Sorry for the delay, thanks a lot for your reply. I will check if any snapshots were created before the range tombstones and not be released. Another question is: Consider a compaction generate two files in the same level.

1.sst
range: [a,f)
tombstone [a,1,c] [e,1,i]

2.sst
range: [g,y)

Will the tombstone[e,1,i] be stored in 2.sst? If not, when we new iterator and seek("g"), how to find that it has been deleted, @abhimadan

yangzhijia avatar Dec 17 '18 10:12 yangzhijia

Yes, the tombstone will be stored in both files. As you've noticed, seeking in the DB becomes tricky when a range tombstone that covers some keys in a file doesn't exist in that file, so we duplicate the range tombstone across all files whose boundaries it overlaps.

abhimadan avatar Dec 17 '18 18:12 abhimadan