Repository navigation
fix: narrow pessimistic insert table lock window - #24201
Merged
mergify[bot] merged 4 commits intoApr 25, 2026
Merged
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR narrows the pessimistic table-lock hold window for INSERT ... SELECT ... by preventing Compile.prePipelineInitializer() from pre-acquiring table locks for Query_INSERT, deferring acquisition to the runtime LockOp instead.
Changes:
- Add
Compile.shouldPrePipelineLockTable()to decide whether a table lock should be acquired pre-pipeline. - Update
compileLock()to useshouldPrePipelineLockTable()(skipping pre-pipeline table locks forINSERT). - Add a unit test covering
shouldPrePipelineLockTable()behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/sql/compile/compile.go | Introduces conditional pre-pipeline table locking and applies it to lock-target handling in compileLock(). |
| pkg/sql/compile/compile_test.go | Adds a focused unit test for the new pre-pipeline lock decision helper. |
ouyuanning
approved these changes
Apr 25, 2026
aunjgr
approved these changes
Apr 25, 2026
Co-authored-by: Copilot <[email protected]>
XuPeng-SH
approved these changes
Apr 25, 2026
Contributor
Merge Queue Status
This pull request spent 11 seconds in the queue, including 1 second running CI. Required conditions to merge
|
jiangxinmeng1
pushed a commit
to jiangxinmeng1/matrixone
that referenced
this pull request
Apr 27, 2026
This PR narrows the lock hold window for pessimistic `INSERT ... SELECT ...` statements that were escalated to table locks. Before this change, `Compile.prePipelineInitializer()` acquired the target table lock before the source side of the pipeline started running, which let large source scans hold the target table lock for too long and block later writers. The change keeps table-lock semantics intact but skips pre-pipeline table locking for `Query_INSERT`, allowing the existing `LockOp` in the execution pipeline to acquire the table lock closer to the actual write path. A focused compile test is added to lock the intended timing behavior. Approved by: @ouyuanning, @aunjgr, @XuPeng-SH
1 of 7 tasks
mergify Bot
pushed a commit
that referenced
this pull request
Apr 27, 2026
PR #24201 moved Query_INSERT table locking off the pre-pipeline path. LOAD DATA is also planned as Query_INSERT and always carries a table-locking LockOp, so TPCH 1T load started taking that path too and the nightly load phase regressed noticeably after b79773d. This patch keeps the #24201 behavior for regular INSERT statements, but restores the pre-pipeline table lock for LOAD DATA only. That keeps the fix scope narrow and avoids changing unrelated INSERT paths again. A compile test was added to lock the routing behavior between regular INSERT and LOAD DATA. Approved by: @ouyuanning, @XuPeng-SH
1 of 7 tasks
LeftHandCold
added a commit
to LeftHandCold/matrixone
that referenced
this pull request
Apr 29, 2026
Backport matrixorigin#24201 to main. Co-authored-by: Copilot <[email protected]>
mergify Bot
pushed a commit
that referenced
this pull request
Apr 29, 2026
This backports #24201 to `main`. For pessimistic `INSERT ... SELECT ...` statements that escalate to table locks, `Compile.compileLock` was still keeping the target table on the pre-pipeline lock path. That can make a large source scan hold the target-table lock before the write side starts running and block later writers for too long. This backport keeps the same table-lock semantics, but lets `LockOp` acquire the table lock when the first batch reaches the target pipeline. It also preserves EOF-time table locking for the zero-row path so inserts that produce no rows still keep the intended table-lock behavior. Also included: - a compile unit test for the pre-pipeline lock routing - a lockop unit test for the zero-row EOF table-lock path Approved by: @aunjgr, @ouyuanning, @iamlinjunhong
fengttt
pushed a commit
to fengttt/matrixone
that referenced
this pull request
May 7, 2026
This backports matrixorigin#24201 to `main`. For pessimistic `INSERT ... SELECT ...` statements that escalate to table locks, `Compile.compileLock` was still keeping the target table on the pre-pipeline lock path. That can make a large source scan hold the target-table lock before the write side starts running and block later writers for too long. This backport keeps the same table-lock semantics, but lets `LockOp` acquire the table lock when the first batch reaches the target pipeline. It also preserves EOF-time table locking for the zero-row path so inserts that produce no rows still keep the intended table-lock behavior. Also included: - a compile unit test for the pre-pipeline lock routing - a lockop unit test for the zero-row EOF table-lock path Approved by: @aunjgr, @ouyuanning, @iamlinjunhong
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
This backports matrixorigin#24201 to `main`. For pessimistic `INSERT ... SELECT ...` statements that escalate to table locks, `Compile.compileLock` was still keeping the target table on the pre-pipeline lock path. That can make a large source scan hold the target-table lock before the write side starts running and block later writers for too long. This backport keeps the same table-lock semantics, but lets `LockOp` acquire the table lock when the first batch reaches the target pipeline. It also preserves EOF-time table locking for the zero-row path so inserts that produce no rows still keep the intended table-lock behavior. Also included: - a compile unit test for the pre-pipeline lock routing - a lockop unit test for the zero-row EOF table-lock path Approved by: @aunjgr, @ouyuanning, @iamlinjunhong
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
This backports matrixorigin#24201 to `main`. For pessimistic `INSERT ... SELECT ...` statements that escalate to table locks, `Compile.compileLock` was still keeping the target table on the pre-pipeline lock path. That can make a large source scan hold the target-table lock before the write side starts running and block later writers for too long. This backport keeps the same table-lock semantics, but lets `LockOp` acquire the table lock when the first batch reaches the target pipeline. It also preserves EOF-time table locking for the zero-row path so inserts that produce no rows still keep the intended table-lock behavior. Also included: - a compile unit test for the pre-pipeline lock routing - a lockop unit test for the zero-row EOF table-lock path Approved by: @aunjgr, @ouyuanning, @iamlinjunhong
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
This backports matrixorigin#24201 to `main`. For pessimistic `INSERT ... SELECT ...` statements that escalate to table locks, `Compile.compileLock` was still keeping the target table on the pre-pipeline lock path. That can make a large source scan hold the target-table lock before the write side starts running and block later writers for too long. This backport keeps the same table-lock semantics, but lets `LockOp` acquire the table lock when the first batch reaches the target pipeline. It also preserves EOF-time table locking for the zero-row path so inserts that produce no rows still keep the intended table-lock behavior. Also included: - a compile unit test for the pre-pipeline lock routing - a lockop unit test for the zero-row EOF table-lock path Approved by: @aunjgr, @ouyuanning, @iamlinjunhong
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 #24200
What this PR does / why we need it:
This PR narrows the lock hold window for pessimistic
INSERT ... SELECT ...statements that were escalated to table locks. Before this change,Compile.prePipelineInitializer()acquired the target table lock before the source side of the pipeline started running, which let large source scans hold the target table lock for too long and block later writers.The change keeps table-lock semantics intact but skips pre-pipeline table locking for
Query_INSERT, allowing the existingLockOpin the execution pipeline to acquire the table lock closer to the actual write path. A focused compile test is added to lock the intended timing behavior.