Skip to content
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

Conversation

jeffrey-xiao
Copy link
Contributor

@jeffrey-xiao jeffrey-xiao commented Aug 19, 2019

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.

@jeffrey-xiao jeffrey-xiao force-pushed the fix-range-deletion-tombstone-ingestion-with-global-seqno branch 2 times, most recently from cf3106f to 5cec264 Compare August 19, 2019 18:51
@jeffrey-xiao jeffrey-xiao marked this pull request as ready for review August 19, 2019 18:52
@jeffrey-xiao jeffrey-xiao reopened this Aug 19, 2019
@ajkr
Copy link
Contributor

ajkr commented Aug 29, 2019

@siying what do you think about moving global_seqno_ out of Block and instead obtaining it from BlockBasedTableReader? That prevents us from seeing wrong seqnum for blocks that are accessed and cached during file ingestion preparation. There are a couple benefits.

(1) we can remove this workaround for data blocks:

// During reading the external file we can cache blocks that we read into
// the block cache, if we later change the global seqno of this file, we will
// have block in cache that will include keys with wrong seqno.
// We need to disable fill_cache so that we read from the file without
// updating the block cache.
ro.fill_cache = false;

(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

@siying
Copy link
Contributor

siying commented Aug 29, 2019

@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.
@jeffrey-xiao jeffrey-xiao force-pushed the fix-range-deletion-tombstone-ingestion-with-global-seqno branch from 5cec264 to 7b49d1b Compare August 30, 2019 02:37
@siying siying requested a review from ltamasi September 5, 2019 23:51
@ajkr
Copy link
Contributor

ajkr commented Nov 1, 2019

I think this is an important fix. If Jeffrey's not available to rebase I can do it once review looks promising.

@ajkr
Copy link
Contributor

ajkr commented Jan 18, 2020

Ping @ltamasi. Rebased anyways as I still think this is an important fix. Please let me know any questions.

Copy link
Contributor

@ltamasi ltamasi left a 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();
Copy link
Contributor

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");
Copy link
Contributor

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,
Copy link
Contributor

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 Blocks are constructed and fix any problems like this.

@ltamasi
Copy link
Contributor

ltamasi commented Jan 24, 2020

Also, could you mention the fix in HISTORY.md?

@ajkr
Copy link
Contributor

ajkr commented Feb 19, 2020

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.

@ajkr ajkr closed this Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants