Repository navigation
Conversation
Backport matrixorigin#30268 to 4.2-dev to prevent LIMIT from suppressing a pending locking-read retry. Keep the production callNonBlocking implementation identical to main and preserve streaming execution without a conflict. Adapt only tests to the release branch: provide the missing timestamp waiter and waiter-count helpers, update the three existing retry timing assertions, and retain the committed-row result for the RR session cells confirmed by the unmodified no-LIMIT control. (cherry picked from commit 493d8b8)
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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the complete six-file change at ca03435 against 4.2-dev / 9adce30. No blocking findings.
The ownership/design is appropriate: LockOp retains the existing pending-retry and collect-all-locks policy, while Compile continues to own statement rollback/retry and blocking Output owns buffered results. The fix prevents a stale batch from reaching LIMIT and hiding the retry. It adds no parallel state machine, batch cache, transaction mechanism or configuration. Cancellation is checked through ChildrenCall/Exec on every pull; child/lock errors remain terminal and a later definition change retains the stronger retry error.
The production function is byte-identical to the merged main fix in #30268. I independently checked the release-specific RR behavior: with only the production function reverted to base, RC and RR no-LIMIT controls return 1, whereas both LIMIT cases incorrectly return 0. The head passes both. Preserving 4.2's behavior rather than importing main's RR conflict-error expectation is correct for this backport.
Independent local verification, macOS arm64 / Go 1.26.4:
- Complete lockop package: 134 named passes in normal mode and 134 under race.
- Seven affected/control test roots repeated separately under race, using measured 30-second budgets: 58 / 100 / 100 / 81 / 100 / 100 / 100 iterations; all passed.
- All 11 public SQL scenarios passed normal, race and the adaptive focused race repeat, using the existing 3-CN fixture and real SQL connections to two CNs. Includes binary prepared reuse, session limit, shared lock, holder rollback, remote owner, RR settings and UPDATE after waiting.
- Three reviewer-only boundary cases passed: conflict after an already buffered prefix, pending retry followed by a clean batch, and LIMIT stopping before a later unrelated conflict. Reverting production to base also fails the operator LIMIT regression while its uncontended control passes.
- Exact BVT case ran twice in normal comparison mode on the same clean, exact-head service: 31/31 each, zero ignored/abnormal cases; database absence verified between and after runs. SQL and ISCP readiness checked; service exited cleanly.
- Native/service build, gofmt/diff checks and configured incremental golangci-lint 2.6.2 over both affected packages passed; incremental SCA reported 0 issues.
Test additions reuse existing fixtures, minimal rows and a real waiter barrier, with distinct operator/protocol/cleanup oracles. Implementation delta is +22/-18, tests +534/-3, documentation 0. No technical review threads are currently outstanding.
Performance qualification: the uncontended path remains one-pull streaming, without new batch copies, retained buffers or RPCs. After a conflict, a LIMIT query can scan/lock additional remaining input to preserve the existing lock-before-retry policy. This is an explicit cost; I have not measured TP throughput or claimed zero cost in every workload. The separate lock-range efficiency issue #30253 is outside this fix.
The initial local SQL attempt failed before executing scenarios because another local test occupied the port range; rerunning with the shared port/admission namespace passed. That environment failure and intentional base negative controls were not counted as passing evidence. GitHub's full UT/SCA/BVT jobs are still running at review submission; this approval does not claim those merge gates are green.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #30245 (4.2 release line).
What this PR does / why we need it:
Backport #30268 (main commit
493d8b8181b7d74bed91e360874a3dd35223f276) to4.2-dev.A locking read with
LIMIT 1can return an obsolete row after waiting for a concurrent update because LIMIT stops pulling before LockOp reports its pending retry. The backport drains and locks the remaining input without forwarding obsolete batches, then returns the retry. Uncontended execution remains streaming. The production function is identical to the merged main fix; no other production code changes.Release compatibility adaptations are limited to tests: add the timestamp-waiter and actual-waiter probes absent on this branch, update the three existing retry-timing expectations, and retain 4.2's committed-row result for the RR session cases. The unchanged release source passes both no-LIMIT controls but fails both LIMIT controls with old value
0instead of1; this backport passes all 11 SQL scenarios. Main-only definition-fence tests are not introduced.Validation on Linux amd64 / Go 1.26.4, based on
9adce306ff4efa9754fd8d9cce051386a1eb0190:make -j4 cgoand used the repository CGo test wrapper.1, while LIMIT reads return0before the fix.locking_read_limit_retry.sql: normal mo-tester comparison twice on the same fresh instance, 31/31 statements each; database removal verified between runs and after the second run; fixture stopped.go vet, gofmt, and diff checks passed for the affected packages.Tradeoff: a pending retry finishes acquiring the remaining input locks, so a conflicting limited query can process additional input. This preserves the existing lock-acquisition policy. Full release CI remains pending; this PR does not itself publish a new 4.2.x release.