Repository navigation
vtgate: preserve evaluated IN tuples on lookup-miss fallback - #22150
Open
patnaikankit wants to merge 1 commit into
Open
patnaikankit wants to merge 1 commit into
patnaikankit wants to merge 1 commit into
Conversation
Resolve marked IN fallbacks while the evaluated routing values are still available, preserving single-column and indexed multi-column bindings without re-evaluation. Add deterministic changing-expression and UUID regressions for buffered, streaming, and VEXPLAIN execution. Signed-off-by: Ankit Patnaik <ankit.123patnaik123@gmail.com>
patnaikankit
requested review from
arthurschreiber and
frouioui
as code owners
November 24, 2026 07:17
Contributor
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The review identifies no active issues with the change preserving evaluated IN values during arbitrary-shard fallback.
No open issues 🎉
What changed in this PR
Fixes #22149 by preserving evaluated IN values when a marked VTGate route has no destinations and falls back to an arbitrary shard. This engine-only change is independent of the related UNION planner work.
Changes:
- Resolve marked IN fallbacks within routing helpers, reusing evaluated tuples for shard bindings.
- Preserve indexed composite lists and reuse scalar evaluation results without modifying caller bindings.
- Add regression coverage for changing expressions, repeated Route execution, buffered and streaming execution, and VEXPLAIN.
| File | Description |
|---|---|
go/vt/vtgate/engine/routing.go |
Retains evaluated IN values for fallback bindings and removes duplicate scalar evaluation. |
go/vt/vtgate/engine/route.go |
Directs marked IN routes through fallback-aware routing helpers. |
go/vt/vtgate/engine/route_in_fallback_test.go |
Tests tuple reuse, composite bindings, and execution-local values. |
Review effort: Balanced
2 of 5 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A marked IN route can find no lookup destinations but still need arbitrary-shard execution, for example for an aggregate result or an independent reference UNION arm. Its fallback must use the tuple that routing already evaluated. Re-evaluating a nondeterministic expression can change the list; sending only the original caller bindings can instead omit the generated list variable.
Resolve marked IN fallbacks inside the IN routing helpers while their evaluated values are still available, then build shard bindings through the existing helpers. Preserve single-column
__valsand indexed multi-column lists, omit scalar-column list bindings, and reuse scalar evaluation results. Values remain local to each execution; caller bindings and cached route expressions are unchanged.Regression coverage compares the routed values with the final fallback tuple using both
uuid()and a deterministic changing expression. It exercises buffered, streaming and VEXPLAIN execution, repeated use of one Route, and composite list/scalar combinations.This PR is based directly on main and contains only the tuple-preservation fix and tests. It does not include #21962 or #21354. The reference-UNION issue was reported during #21962's review, but the engine fix also applies to existing marked IN fallbacks. When #21962 lands, its overlapping fallback code should be reconciled with this shared routing path.
Related Issue(s)
Fixes #22149
Related to #21962 and its nonblocking follow-up review.
Validation
823174c29a) without the fix, and also detect the tuple mismatch and duplicate evaluation on vtgate: preserve reference rows in UNION ALL on lookup miss #21962's unchanged implementation.scripts/fmt, engine lint andgit diff --checkpass.No end-to-end cluster run was performed for this follow-up. Fresh CI results are pending.
Checklist
Deployment Notes
No configuration, schema or deployment changes are required. Marked IN fallback queries retain the values already checked during routing. Ordinary lookup-only misses remain empty results. No backport is requested.
Arbitrary-shard selection is unchanged. In
transaction_mode=SINGLE, a fallback can still select another shard and triggermulti-db transaction attempted; transaction affinity is outside this fix.AI Disclosure
Codex assisted with implementation, regression tests and validation.