fix: abort explicit txn on lock bind change#24354
Merged
mergify[bot] merged 7 commits intoMay 12, 2026
Merged
Conversation
A lock table bind change means the lockservice owner epoch has changed. Retrying transparently inside an explicit user transaction can keep using stale transaction context across the old/new bind boundary after CN restart. Return ErrLockTableBindChanged directly for explicit user transactions so frontend rolls back the whole txn, while preserving retry for autocommit and internal transactions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ouyuanning
approved these changes
May 12, 2026
Contributor
Merge Queue Status
This pull request spent 1 hour 11 minutes 45 seconds in the queue, including 59 minutes 32 seconds running CI. Required conditions to merge
|
This was referenced May 12, 2026
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:
refs #24346
What this PR does / why we need it:
This PR adds a necessary guard for explicit user transactions when lock retry sees
ErrLockTableBindChangedafter a CN restart / lockservice owner epoch change.The existing retry path treats
ErrLockTableBindChangedas retryable for all transactions. That remains acceptable for autocommit statements and internal retry paths, because the statement can be retried from the statement boundary without carrying explicit multi-statement transaction state. It is unsafe for explicit user transactions: retrying the lock inside the same transaction can continue with stale transaction / lock context across the old and new lock table binds after CN OOM/restart.This PR changes lock retry so explicit user transactions return
ErrLockTableBindChangeddirectly and let the frontend roll back the whole transaction. That includes:autocommit=0BEGINtransactions where the session autocommit variable remains enabledAutocommit user statements and internal transactions keep the existing retry behavior, so this avoids changing the normal customer-facing autocommit retry path while still covering the TPCC explicit transaction failure mode.
This is not the full protocol-level fix for #24346. The complete fix needs lockservice old-bind active transaction fencing so CNs abort in-flight transactions that still hold lock table binds invalidated by allocator rebind/removal.
Also included:
BEGINtransactions, and preserved autocommit retry behaviorValidation
PROJECTROOT="/Users/shenjiangwei/Work/code/view/matrixone"export CGO_CPPFLAGS="-I$PROJECTROOT/cgo -I$PROJECTROOT/thirdparties/install/include"export CGO_CFLAGS="-I$PROJECTROOT/cgo -I$PROJECTROOT/thirdparties/install/include"export CGO_LDFLAGS="-Wl,-w,-rpath,$PROJECTROOT/thirdparties/install/lib -L$PROJECTROOT/thirdparties/install/lib -L$PROJECTROOT/cgo -lmo"go test ./pkg/sql/colexec/lockop -count=1