release-26.1: sql: fix nil LeafTxnInputState assertion in inner plans#164579
release-26.1: sql: fix nil LeafTxnInputState assertion in inner plans#164579blathers-crl[bot] wants to merge 1 commit intorelease-26.1from
Conversation
Previously, when inner plans (such as apply-join iterations or routines) were executed with a LeafTxn inherited from an outer plan, an assertion failure could occur. The issue was that `MakeLeafTxn` was always set on the flow context, even when `LeafTxnInputState` was not available. When a JoinReader in the inner plan called `UseStreamer()`, it would see that `flowCtx.Txn.Type() == kv.LeafTxn` and `flowCtx.MakeLeafTxn != nil`, and attempt to create a new leaf transaction. This would hit the assertion "nil LeafTxnInputState when trying to create the LeafTxn" because inner plans that inherit a LeafTxn cannot call `GetLeafTxnInputState()` (that method only works on RootTxn). This commit fixes the issue by only setting `MakeLeafTxn` on the flow context when `LeafTxnInputState` is actually available. This way, `UseStreamer()` will see `MakeLeafTxn == nil` and simply use the existing `flowCtx.Txn` directly instead of trying to create a new leaf transaction. (No release note because this is a rare failure.) Fixes: #161168 Release note: None Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
d8653ca to
2f4a78c
Compare
|
Thanks for opening a backport. Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate. |
|
It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
yuzefovich
left a comment
There was a problem hiding this comment.
@yuzefovich reviewed 2 files and all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on michae2).
Backport 1/1 commits from #161222 on behalf of @michae2.
Previously, when inner plans (such as apply-join iterations or routines) were executed with a LeafTxn inherited from an outer plan, an assertion failure could occur. The issue was that
MakeLeafTxnwas always set on the flow context, even whenLeafTxnInputStatewas not available.When a JoinReader in the inner plan called
UseStreamer(), it would see thatflowCtx.Txn.Type() == kv.LeafTxnandflowCtx.MakeLeafTxn != nil, and attempt to create a new leaf transaction. This would hit the assertion "nil LeafTxnInputState when trying to create the LeafTxn" because inner plans that inherit a LeafTxn cannot callGetLeafTxnInputState()(that method only works on RootTxn).This commit fixes the issue by only setting
MakeLeafTxnon the flow context whenLeafTxnInputStateis actually available. This way,UseStreamer()will seeMakeLeafTxn == niland simply use the existingflowCtx.Txndirectly instead of trying to create a new leaf transaction.(No release note because this is a rare failure.)
Fixes: #161168
Release note: None
Release justification: low-risk change to fix a test failure.