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

scan subcompaction split point covered by range dels #71

Merged
merged 1 commit into from
Dec 17, 2019

Conversation

ajkr
Copy link

@ajkr ajkr commented Dec 16, 2019

Fix an infinite loop in range tombstone seek-to-end-key optimization. It
happened when a range tombstone was split according to its containing
files' boundaries. In particular, the split point had to have a lower
sequence number than a point key at the same user key in a file that the
range tombstone covered.


This change is Reviewable

@ajkr ajkr requested a review from petermattis December 16, 2019 20:07
@ajkr
Copy link
Author

ajkr commented Dec 16, 2019

I do not see a problem for backwards scanning but who knows. In that case, the internal key is forged with the tombstone seqnum, and SeekForPrev()ing to that point feels like it must make progress in moving backwards. Whereas in this bug, in forward scan we were seeking to a point that was actually before the current key, thus no progress was made.

@ajkr ajkr force-pushed the 5.13-fix-range-del-inf-loop branch 2 times, most recently from b899db7 to f201267 Compare December 17, 2019 00:30
Copy link

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @ajkr and @petermattis)


table/block_based_table_reader.cc, line 1795 at r1 (raw file):

  if (range_tombstone_.seq() > 0 &&
      (!Valid() ||
       icomp_.Compare(key(), tombstone_internal_end_key()) < 0)) {

Using Valid() and key() here seems suspicious as we haven't seeked the iterator yet. I'm not clear on why this portion of the change is necessary. Can you provide some commentary?

Also, is this part of the change tested in some way? Unless I'm missing something, the test you added only seems to cover the FindKeyForward problem.

Copy link
Author

@ajkr ajkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @petermattis)


table/block_based_table_reader.cc, line 1795 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

Using Valid() and key() here seems suspicious as we haven't seeked the iterator yet. I'm not clear on why this portion of the change is necessary. Can you provide some commentary?

Also, is this part of the change tested in some way? Unless I'm missing something, the test you added only seems to cover the FindKeyForward problem.

I added it for symmetry. It is not needed for preventing infinite loop. It just prevents one repetitive seek in rare cases. Also it should be comparing target rather than key(). Will remove it for simplicity.

Even though we're removing it, it's still reasonable to make the test also hit the Seek() path, particularly seeking to the split point user key.

@ajkr ajkr force-pushed the 5.13-fix-range-del-inf-loop branch from f201267 to f477f06 Compare December 17, 2019 04:48
Fix an infinite loop in range tombstone seek-to-end-key optimization. It
happened when a range tombstone was split according to its containing
files' boundaries. In particular, the split point had to have a lower
sequence number than a point key at the same user key in a file that the
range tombstone covered.
@ajkr ajkr force-pushed the 5.13-fix-range-del-inf-loop branch from f477f06 to 47196b4 Compare December 17, 2019 04:49
Copy link
Author

@ajkr ajkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR. RFAL.

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @petermattis)


table/block_based_table_reader.cc, line 1795 at r1 (raw file):

Previously, ajkr (Andrew Kryczka) wrote…

I added it for symmetry. It is not needed for preventing infinite loop. It just prevents one repetitive seek in rare cases. Also it should be comparing target rather than key(). Will remove it for simplicity.

Even though we're removing it, it's still reasonable to make the test also hit the Seek() path, particularly seeking to the split point user key.

Done.

Copy link

@petermattis petermattis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @ajkr)


table/block_based_table_reader.cc, line 1795 at r1 (raw file):

Previously, ajkr (Andrew Kryczka) wrote…

Done.

Ack.

@ajkr ajkr merged commit 53041f9 into cockroachdb:crl-release-5.13 Dec 17, 2019
ajkr added a commit to ajkr/cockroach that referenced this pull request Dec 17, 2019
Picks up cockroachdb/rocksdb#71.

Release note (bug fix): Prevent rare case of infinite looping query on
database files written with a Cockroach version pre-2.1.9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants