Repository navigation
fix(frontend): force recompile on each prepared execute to prevent hang - #25562
Merged
Merged
Conversation
Prepared UPDATE...JOIN hangs on second execution through binary protocol (COM_STMT_EXECUTE) because the cached compile retained stale operator state (e.g. hashbuild ctr, dispatch channels) across executions. Scan receivers block forever in waitForRuntimeFilters waiting for runtime filter messages that never arrive because hashbuild operators stall in build() on re-execution. Fix: restructure initExecuteStmtParam to always release the cached compile and create a fresh one with isPrepare=true. This avoids: - Resource leaks (proper FreeOperator+Release before replacement) - Execution path drift (isPrepare=true preserved for exec type decisions) - State mutation in read paths (consistent recreation for all callers) The compile is freshly built from the plan each execution; the plan is still cached and reused when no schema change is detected. Fixes: matrixorigin#25526 Co-Authored-By: Claude <[email protected]>
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? |
Only rebuild the prepared-statement compile when a cached compile exists. A nil cache means the statement was rejected for prepare-time compile (e.g. AP query); unconditionally retrying failed with ErrCantCompileForPrepare on every execution, adding a wasted compile attempt per EXECUTE. TP statements keep the force-recreate semantics that fix the stale-operator-state hang. Also fixes the SCA gofmt failure (stray tab on an empty line) and adds: - UTs for the rebuild logic (skip-without-cache, recreate-with-cache, surface recompile error), modified-block coverage 80% - BVT for repeated execution of a prepared UPDATE...JOIN Verified the original repro (binary protocol COM_STMT_EXECUTE twice) completes without hang. Fixes: matrixorigin#25526 Co-Authored-By: Claude Fable 5 <[email protected]>
ghost
approved these changes
Jul 10, 2026
Contributor
Merge Queue Status
This pull request spent 1 hour 59 minutes 29 seconds in the queue, including 1 hour 21 minutes 44 seconds running CI. Required conditions to merge
|
1 of 7 tasks
This branch was previously 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.
What type of PR is this?
Which issue(s) this PR fixes:
issue #25526
What this PR does / why we need it:
Fix prepared UPDATE...JOIN hanging on second execution through binary protocol
(COM_STMT_EXECUTE). First execution succeeds, second hangs forever.
Root Cause: The
initExecuteStmtParamfunction caches and reuses a compiledscope tree (
prepareStmt.compile) across executions when no schema change isdetected. After the first execution, operators in the cached compile retain stale
state (e.g. hashbuild ctr, dispatch channels) from the
isPrepare=truecleanuppath that skips
Free(). On re-execution, hashbuild operators enterCallbutstall in
build()→ never reachhandleRuntimeFilter→ never send runtimefilter messages → scan receivers block forever in
waitForRuntimeFilters(confirmed via goroutine dump).
Fix: Restructure
initExecuteStmtParamto always release the cached compile(via
FreeOperator+SetIsPrepare(false)+Release) and create a fresh onewith
isPrepare=trueon every execution. This follows the same pattern thechange=truepath already used. The plan remains cached and reused; only thecompile (lightweight scope tree) is rebuilt. This avoids:
isPrepare=truepreserved forGetExecType)Verification: Reproduced with Go driver (
interpolateParams=false) onsingle-node mo-service. Goroutine dump confirmed scan receivers blocked in
MessageReceiver.ReceiveMessagewith hashbuild never sending runtime filters.After fix: both executions complete normally.
🤖 Generated with Claude Code