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

internal/keyspan: obey Seek invariants in filteringIter #3046

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

itsbilal
Copy link
Contributor

@itsbilal itsbilal commented Nov 8, 2023

Previously if filteringIter's FilterFunc mutated the passed-in span to no longer be a valid return value for a SeekLT or SeekGE call, we would still return that span even though it could be >= the seek key (for SeekLT), or less than it (for SeekGE).

This change updates filteringIter to guard for this case before returning from a seek call.

Found with #3044.

Informs cockroachdb/cockroach#113973, cockroachdb/cockroach#114056.

@itsbilal itsbilal requested review from erikgrinaker, a team and jbowens November 8, 2023 22:13
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@itsbilal
Copy link
Contributor Author

itsbilal commented Nov 8, 2023

This needs a test. I'll write one within the next hour.

Previously if filteringIter's FilterFunc mutated the passed-in span
to no longer be a valid return value for a SeekLT or SeekGE call,
we would still return that span even though it could be >=  the seek
key (for SeekLT), or less than it (for SeekGE).

This change updates filteringIter to guard for this case before
returning from a seek call.

Found with cockroachdb#3044.

Informs cockroachdb/cockroach#113973, cockroachdb/cockroach#114056.
@itsbilal
Copy link
Contributor Author

itsbilal commented Nov 8, 2023

Tests added.

Copy link
Collaborator

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

Nice find.

:lgtm:

Do you mind filing an issue about refactoring keyspan.Truncate? If we don't use keyspan.Filter and implement keyspan.FragmentIterator we can avoid the key comparison when we don't truncate.

Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @erikgrinaker)

@itsbilal
Copy link
Contributor Author

itsbilal commented Nov 9, 2023

TFTR! Filed #3048.

I should backport this too right?

@itsbilal itsbilal merged commit 8574e51 into cockroachdb:master Nov 9, 2023
11 checks passed
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.

3 participants