Repository navigation
fix(txn): preserve cached plan generation across transactions - #27738
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
aunjgr
left a comment
There was a problem hiding this comment.
Approved exact head .\n\nThe fix preserves the required invariant: a reusable logical plan is bound to its compilation snapshot, ordinary retry/reset keeps that binding, and a definition-change retry publishes the rebuilt plan and new snapshot only after physical compilation succeeds. Prepared/session cache invalidation, child and remote propagation, result-metadata freezing, and the v32 lock-boundary downgrade guard cover the important ownership and mixed-version edges. The exact-head multi-CN pessimistic BVT passed, and I found no remaining correctness, lifecycle, or protocol blocker.
aunjgr
left a comment
There was a problem hiding this comment.
Approved exact head e6c342e6a4f5ecb78cafa3dad97aab11f7008097.
The fix preserves the required invariant: a reusable logical plan is bound to its compilation snapshot, ordinary retry/reset keeps that binding, and a definition-change retry publishes the rebuilt plan and new snapshot only after physical compilation succeeds. Prepared/session cache invalidation, child and remote propagation, result-metadata freezing, and the v32 lock-boundary downgrade guard cover the important ownership and mixed-version edges. The exact-head multi-CN pessimistic BVT passed, and I found no remaining correctness, lifecycle, or protocol blocker.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep-reviewed exact head e6c342e6a4f5ecb78cafa3dad97aab11f7008097 against base b0ae66c04d9a67175d2dfb8bf1c777fb888e1430.
The fix addresses #27659 at the actual violated invariant: the retained DDL fence is compared with the immutable logical-plan generation snapshot, while transaction CreateTS keeps its separate rolling-restart role. Prepared and session caches carry plan + snapshot as one generation; Reset and data-only retry preserve it; a definition retry publishes a newly compiled plan/snapshot only after successful physical compilation and invalidates stale frontend topology on every failed rebuild path.
Lifecycle/unhappy-path audit:
- Q1 ownership: Compile owns the generation binding; Process only transports it and clears it at Release. Cached prepared topology, runtime specialization, and borrowed session-cache AST retain distinct release owners; the invalidation paths avoid double Release.
- Q2 termination: definition retry uses the existing bounded retry machinery. Protocol rollback is rechecked at the final lock boundary; RC rebuilds locally, while SI preserves WW-conflict semantics.
- Q3 growth: session-cache timestamps are bounded by the existing LRU entries, prepared state adds constant-size fields, and no retry-owned generation is retained after terminal failure.
Remote child/codec propagation and old-sender fallback are coherent. Result metadata is frozen before streaming and incompatible rebuilt schemas fail before row execution; RETURNING delays metadata until its attempt spool succeeds. The ordinary path adds no RPC, polling, catalog lookup, or unconditional rebuild; current generations omit the optional lock payload.
I reviewed the full non-generated diff and focused tests, verified git diff --check, and exact-head CI is green, including multi-CN pessimistic and Proxy BVT. I found no blocking correctness, performance, race/lifecycle, hang, or leak issue.
Merge Queue Status
This pull request spent 2 minutes 28 seconds in the queue, with no time running CI. ReasonPull request #27738 has been dequeued Queue conditions are not satisfied:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Requeued — the merge queue status continues in this comment ↓. |
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed exact head e6c342e6a4f5ecb78cafa3dad97aab11f7008097 against merge-base b0ae66c04d9a67175d2dfb8bf1c777fb888e1430, including the clean merge with current origin/main (424fe3d821e45fe883ab93af5b404d77686d05a0). I found no P0/P1 blocker. Two P2 findings are attached: one correctness gap for SELECT ... INTO arity after a definition retry, and one steady-state plan-cache hit allocation.
Merge Queue Status
This pull request spent 11 minutes 25 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #27738 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
…origin#27738) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#27659 ## What this PR does / why we need it: A cached prepared or session plan can outlive the transaction that compiled it. After a copy-based ALTER TABLE on another CN, using the executing transaction creation timestamp for the retained DDL fence can hide that the plan still references the old table generation. This change: - binds each logical plan generation to its immutable compilation snapshot and carries it through prepared/session caches, retries, child processes, and remote fragments; - compares retained definition fences with that plan snapshot while preserving transaction CreateTS for rolling-restart admission; - adds the MORPC v32 capability gate and a final lock-boundary downgrade guard for mixed-version clusters; - atomically publishes or invalidates rebuilt cached generations and protects streamed result metadata from incompatible definition retries. Validation: - focused prepared/session cache, retry, lock fence, remote codec, and metadata regressions; - full owning-package tests and race tests; - adaptive focused race stress; - relevant package build and vet. Not run locally: live multi-CN rolling-upgrade BVT. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…origin#27738) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#27659 ## What this PR does / why we need it: A cached prepared or session plan can outlive the transaction that compiled it. After a copy-based ALTER TABLE on another CN, using the executing transaction creation timestamp for the retained DDL fence can hide that the plan still references the old table generation. This change: - binds each logical plan generation to its immutable compilation snapshot and carries it through prepared/session caches, retries, child processes, and remote fragments; - compares retained definition fences with that plan snapshot while preserving transaction CreateTS for rolling-restart admission; - adds the MORPC v32 capability gate and a final lock-boundary downgrade guard for mixed-version clusters; - atomically publishes or invalidates rebuilt cached generations and protects streamed result metadata from incompatible definition retries. Validation: - focused prepared/session cache, retry, lock fence, remote codec, and metadata regressions; - full owning-package tests and race tests; - adaptive focused race stress; - relevant package build and vet. Not run locally: live multi-CN rolling-upgrade BVT. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…origin#27738) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#27659 ## What this PR does / why we need it: A cached prepared or session plan can outlive the transaction that compiled it. After a copy-based ALTER TABLE on another CN, using the executing transaction creation timestamp for the retained DDL fence can hide that the plan still references the old table generation. This change: - binds each logical plan generation to its immutable compilation snapshot and carries it through prepared/session caches, retries, child processes, and remote fragments; - compares retained definition fences with that plan snapshot while preserving transaction CreateTS for rolling-restart admission; - adds the MORPC v32 capability gate and a final lock-boundary downgrade guard for mixed-version clusters; - atomically publishes or invalidates rebuilt cached generations and protects streamed result metadata from incompatible definition retries. Validation: - focused prepared/session cache, retry, lock fence, remote codec, and metadata regressions; - full owning-package tests and race tests; - adaptive focused race stress; - relevant package build and vet. Not run locally: live multi-CN rolling-upgrade BVT. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
What type of PR is this?
Which issue(s) this PR fixes:
issue #27659
What this PR does / why we need it:
A cached prepared or session plan can outlive the transaction that compiled it. After a copy-based ALTER TABLE on another CN, using the executing transaction creation timestamp for the retained DDL fence can hide that the plan still references the old table generation.
This change:
Validation:
Not run locally: live multi-CN rolling-upgrade BVT.