Skip to content

release-26.1: sql: fix nil LeafTxnInputState assertion in inner plans#164579

Open
blathers-crl[bot] wants to merge 1 commit intorelease-26.1from
blathers/backport-release-26.1-161222
Open

release-26.1: sql: fix nil LeafTxnInputState assertion in inner plans#164579
blathers-crl[bot] wants to merge 1 commit intorelease-26.1from
blathers/backport-release-26.1-161222

Conversation

@blathers-crl
Copy link

@blathers-crl blathers-crl bot commented Feb 28, 2026

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 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


Release justification: low-risk change to fix a test failure.

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>
@blathers-crl blathers-crl bot requested a review from a team as a code owner February 28, 2026 06:03
@blathers-crl blathers-crl bot force-pushed the blathers/backport-release-26.1-161222 branch from d8653ca to 2f4a78c Compare February 28, 2026 06:03
@blathers-crl blathers-crl bot requested review from yuzefovich and removed request for a team February 28, 2026 06:03
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Feb 28, 2026
@blathers-crl
Copy link
Author

blathers-crl bot commented Feb 28, 2026

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.

@blathers-crl blathers-crl bot requested a review from michae2 February 28, 2026 06:03
@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Feb 28, 2026
@blathers-crl
Copy link
Author

blathers-crl bot commented Feb 28, 2026

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.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@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.

@yuzefovich reviewed 2 files and all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on michae2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-queries SQL Queries Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants