-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix range deletion tombstone ingestion with global seqno #5719
Fix range deletion tombstone ingestion with global seqno #5719
Conversation
cf3106f
to
5cec264
Compare
@siying what do you think about moving (1) we can remove this workaround for data blocks: rocksdb/db/external_sst_file_ingestion_job.cc Lines 409 to 414 in 1729779
(2) seqnums for meta-blocks like range tombstone meta-block will be correct regardless of whether they're placed in cache during file ingestion preparation |
@ajkr I think it is a good idea. |
If we are writing a global seqno for an ingested file, the range tombstone metablock gets accessed and put into the cache during ingestion preparation. At the time, the global seqno of the ingested file has not yet been determined, so the cached block will not have a global seqno. When the file is ingested and we read its range tombstone metablock, it will be returned from the cache with no global seqno. In that case, we use the actual seqnos stored in the range tombstones, which are all zero, so the tombstones cover nothing. This commit removes global_seqno_ variable from Block. When iterating over a block, the global seqno for the block is determined by the iterator instead of storing this mutable attribute in Block. Additionally, this commit adds a regression test to check that keys are deleted when ingesting a file with a global seqno and range deletion tombstones.
5cec264
to
7b49d1b
Compare
I think this is an important fix. If Jeffrey's not available to rebase I can do it once review looks promising. |
Ping @ltamasi. Rebased anyways as I still think this is an important fix. Please let me know any questions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch @jeffrey-xiao and sorry about the delay! The PR looks very good in general; I just have a few comments.
Thanks for the rebase @ajkr !
ASSERT_OK(sst_file_writer.DeleteRange(Key(0), Key(30))); | ||
ExternalSstFileInfo file_info; | ||
Status s = sst_file_writer.Finish(&file_info); | ||
ASSERT_TRUE(s.ok()) << s.ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just say ASSERT_OK(s);
here, or even combine it with the previous line (ASSERT_OK(sst_file_writer.Finish(&file_info));
).
|
||
ASSERT_OK(s); | ||
for (int i = 5; i < 25; i++) { | ||
ASSERT_EQ(Get(Key(i)), "NOT_FOUND"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ASSERT_TRUE(Get(Key(i)).IsNotFound())
would be a bit cleaner here.
@@ -150,8 +150,7 @@ class BlockReadAmpBitmap { | |||
class Block { | |||
public: | |||
// Initialize the block with the specified contents. | |||
explicit Block(BlockContents&& contents, SequenceNumber _global_seqno, | |||
size_t read_amp_bytes_per_bit = 0, | |||
explicit Block(BlockContents&& contents, size_t read_amp_bytes_per_bit = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here (not with the PR per se but with the pre-existing default parameter values) is that removing _global_seqno
changes the meaning of code like this:
Block reader1(std::move(contents), kDisableGlobalSequenceNumber); // kDisableGlobalSequenceNumber is now read_amp_bytes_per_bit !!!
We should review all places where Block
s are constructed and fix any problems like this.
Also, could you mention the fix in HISTORY.md? |
I need to open a new PR with a source branch to which I have permission to push changes. Doing that and replying to comments there: #6429. |
If we are writing a global seqno for an ingested file, the range tombstone metablock gets accessed and put into the cache during ingestion preparation. At the time, the global seqno of the ingested
file has not yet been determined, so the cached block will not have a global seqno. When the file is ingested and we read its range tombstone metablock, it will be returned from the cache with no global seqno. In that case, we use the actual seqnos stored in the range tombstones, which are all zero, so the tombstones cover nothing.
This commit removes global_seqno_ variable from Block. When iterating over a block, the global seqno for the block is determined by the iterator instead of storing this mutable attribute in Block. Additionally, this commit adds a regression test to check that keys are deleted when ingesting a file with a global seqno and range deletion tombstones.