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
release-23.1.12-rc: sql: fix usage of streamer with multiple column families #113107
release-23.1.12-rc: sql: fix usage of streamer with multiple column families #113107
Conversation
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
Not really, but it's a correctness issue that we need to fix unconditionally. We are introducing an additional session variable that could help us with similar bugs in the future.
InOrder mode of streamer is less efficient, so this could cause performance regression. Choosing InOrder mode when not strictly necessary will never lead to a correctness issue, and should the performance become a concern we can always recommend disabling the streamer to a user.
Our users will continue running into internal errors or incorrect results.
Yes, it fixes a critical correctness issue. |
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.
LGTM
e8260b3
to
9c9465e
Compare
Previously, we had the following bug in how the streamer was used under the following conditions: - we're looking up into a table with at least 3 column families - not all column families are needed, so we end up creating "family-specific" spans (either Gets or Scans - the latter is possible when multiple contiguous families are needed) - the streamer is used with OutOfOrder mode (which is the case for index joins when `MaintainOrdering` is `false` and for lookup joins when `MaintainLookupOrdering` is `false`) - the index we're looking up into is split across multiple ranges. In such a scenario we could end up with KVs from different SQL rows being intertwined because the streamer could execute a separate BatchRequest for those rows, and in case `TargetBytes` limit estimate was insufficient, we'd end up creating "resume" batches, at which point the "results" stream would be incorrect. Later, at the SQL fetcher level this could either manifest as an internal "non-nullable column with no value" error or with silent incorrect output (we'd create multiple output SQL rows from a true single one). This problem is now fixed by asking the streamer to maintain the ordering of the requests whenever we have `SplitFamilyIDs` with more than one family, meaning that we might end up creating family-specific spans. Note that the non-streamer code path doesn't suffer from this problem because there we only parallelize BatchRequests when neither `TargetBytes` nor `MaxSpanRequestKeys` limits are set, which is the requirement for having "resume" batches. Release note (bug fix): CockroachDB previously could incorrectly evaluate lookup and index joins into tables with at least 3 column families in some cases (either "non-nullable column with no value" internal error would occur or the query would return incorrect results), and this is now fixed. The bug was introduced in 22.2.
This commit adds `streamer_always_maintain_ordering` session variable that - when set to `true` - forces all current usages of the streamer in SQL layer (lookup and index joins) to ask it to maintain the ordering, even if this is not stricly necessary by the query. This variable is introduced as a possible workaround in case we find more scenarios where we currently are incorrectly using the OutOfOrder mode of the streamer. Release note: None
9c9465e
to
ee002f0
Compare
Backport 2/2 commits from #113019.
/cc @cockroachdb/release
Previously, we had the following bug in how the streamer was used under the following conditions:
MaintainOrdering
isfalse
and for lookup joins whenMaintainLookupOrdering
isfalse
)In such a scenario we could end up with KVs from different SQL rows being intertwined because the streamer could execute a separate BatchRequest for those rows, and in case
TargetBytes
limit estimate was insufficient, we'd end up creating "resume" batches, at which point the "results" stream would be incorrect. Later, at the SQL fetcher level this could either manifest as an internal "non-nullable column with no value" error or with silent incorrect output (we'd create multiple output SQL rows from a true single one).This problem is now fixed by asking the streamer to maintain the ordering of the requests whenever we have
SplitFamilyIDs
with more than one family, meaning that we might end up creating family-specific spans.Note that the non-streamer code path doesn't suffer from this problem because there we only parallelize BatchRequests when neither
TargetBytes
norMaxSpanRequestKeys
limits are set, which is the requirement for having "resume" batches.Addresses: #113013.
Epic: None
Release note (bug fix): CockroachDB previously could incorrectly evaluate lookup and index joins into tables with at least 3 column families in some cases (either "non-nullable column with no value" internal error would occur or the query would return incorrect results), and this is now fixed. The bug was introduced in 22.2.
Release justification: bug fix.