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

storage: fix a bug with reverse scans, multiple column families, and max keys #92643

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

yuzefovich
Copy link
Member

This commit fixes a bug with how we're checking whether the last row has final column family when performing a reverse scan. Previously, we'd incorrectly treat the largest column ID as the "last" one, but with the reverse iteration actually the zeroth column family is the "last" one. As a result, we could return an incomplete row to SQL.

However, there is no production impact to this bug because no user at the SQL layer currently satisfies all the conditions:

  • WholeRowsOfSize option must be used. Currently, it is only used by the streamer;
  • the reverse scan must be requested and MaxSpanRequestKeys must be set - neither is currently done by the streamer.

Epic: None

Release note: None

@yuzefovich yuzefovich requested review from erikgrinaker and a team November 29, 2022 03:58
Copy link
Contributor

@erikgrinaker erikgrinaker left a comment

Choose a reason for hiding this comment

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

Oops, sorry about that. Thanks for the fix!

@@ -1482,7 +1482,26 @@ func cmdScan(e *evalCtx) error {
opts.AllowEmpty = true
}
if e.hasArg("wholeRows") {
opts.WholeRowsOfSize = 10 // arbitrary, must be greater than largest column family in tests
for _, c := range e.td.CmdArgs {
if c.Key == "wholeRows" {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe you tried this already, but can't this use e.scanArg() and fall back to 10 when set to 0?

Either way, the test doc comment should be updated with the new argument.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member Author

@yuzefovich yuzefovich 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: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @erikgrinaker)


pkg/storage/mvcc_history_test.go line 1486 at r1 (raw file):

Previously, erikgrinaker (Erik Grinaker) wrote…

nit: maybe you tried this already, but can't this use e.scanArg() and fall back to 10 when set to 0?

Either way, the test doc comment should be updated with the new argument.

e.scanArg() requires that the value is present, but I thought it would be annoying to add the value everywhere.

Where is the doc comment you're referring to? (I couldn't find it.)

Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

:lgtm: for the pebbleResults change.

Reviewed 1 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @erikgrinaker)

Copy link
Contributor

@erikgrinaker erikgrinaker left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/storage/mvcc_history_test.go line 1486 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

e.scanArg() requires that the value is present, but I thought it would be annoying to add the value everywhere.

Where is the doc comment you're referring to? (I couldn't find it.)

Looks like wholeRows isn't documented at all. It should be listed here:

// scan [t=<name>] [ts=<int>[,<int>]] [resolve [status=<txnstatus>]] k=<key> [end=<key>] [inconsistent] [skipLocked] [tombstones] [reverse] [failOnMoreRecent] [localUncertaintyLimit=<int>[,<int>]] [globalUncertaintyLimit=<int>[,<int>]] [max=<max>] [targetbytes=<target>] [allowEmpty]

…max keys

This commit fixes a bug with how we're checking whether the last row has
final column family when performing a reverse scan. Previously, we'd
incorrectly treat the largest column ID as the "last" one, but with the
reverse iteration actually the zeroth column family is the "last" one.
As a result, we could return an incomplete row to SQL.

However, there is no production impact to this bug because no user at
the SQL layer currently satisfies all the conditions:
- `WholeRowsOfSize` option must be used. Currently, it is only used by
the streamer;
- the reverse scan must be requested and `MaxSpanRequestKeys` must be
set - neither is currently done by the streamer.

Release note: None
Copy link
Member Author

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

TFTRs!

bors r+

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @erikgrinaker)


pkg/storage/mvcc_history_test.go line 1486 at r1 (raw file):

Previously, erikgrinaker (Erik Grinaker) wrote…

Looks like wholeRows isn't documented at all. It should be listed here:

// scan [t=<name>] [ts=<int>[,<int>]] [resolve [status=<txnstatus>]] k=<key> [end=<key>] [inconsistent] [skipLocked] [tombstones] [reverse] [failOnMoreRecent] [localUncertaintyLimit=<int>[,<int>]] [globalUncertaintyLimit=<int>[,<int>]] [max=<max>] [targetbytes=<target>] [allowEmpty]

Added.

@craig
Copy link
Contributor

craig bot commented Nov 29, 2022

Build succeeded:

@craig craig bot merged commit edc6fda into cockroachdb:master Nov 29, 2022
@yuzefovich yuzefovich deleted the fix-storage-limit branch November 29, 2022 23:28
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.

4 participants