Repository navigation
[4.2-dev] fix(pubsub): keep named publication grants on exact account rows - #32987
mergify[bot] merged 14 commits into
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? |
|
Queue requested — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
The targeted two-CN test passes locally with the PR's threshold of 16, as do the focused lock and frontend tests. The named-recipient and DROP coordination is sound for that case, but the new context marker also changes auxiliary metadata-lock behavior and causes ordinary account deletion to fail at another valid threshold; see the inline reproduction. The ACCOUNT ALL/new-account race is separately tracked by #32941 and is not attributed to this PR. There were no prior human review comments. Local Go runs used the available 4.2 native artifacts; the checked-in native source matches this head.
Bind the point-lock requirement to the resolved mo_account target and preserve it through planning, execution and remote operator copies. Auxiliary locks retain their own escalation policy. Take shared metadata keys in bounded batches so restore can revisit them in the same transaction at a row-lock budget of one.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed 0952608 against 4.2-dev 53b3bc7. The earlier blocker is addressed: exact-row enforcement is attached to the resolved mo_account target instead of the whole statement context, and auxiliary shared metadata keys are sorted and batched. The minimum row-lock limit regression covers direct DROP and cluster restore; the original named-recipient isolation test still covers both a targeted and unrelated DROP.
I traced target admission through both planner passes, operator construction, plan copy and remote pipeline encoding, along with the pre-pipeline metadata locks, range/escalation guard, chunk failure and transaction ownership paths. The existing review thread is resolved. No additional blocker found. Green CI and the author-supplied focused and race evidence are reused. The separate ACCOUNT ALL/new-account race remains tracked in #32941; the default threshold on large production catalogs was not measured.
|
mo-bot review · Commit: Review completed. Read the assessment. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: cf9854060bb4f0a53d7520d595605fcc928b46cd
Assessment: request_changes
The PR reuses transactional locking reads to pin named recipients, and segmented bookkeeping lets the requesting CN record an accepted range after a wide grant. The lock owner still needs to preserve existing point locks when it rejects a partly overlapping range.
Model: gpt-6.2-sol / xhigh
Session: 01a20d47-b35e-7bd2-9d5c-61978a866730 · slot 0 · generation 6
- P2
pkg/lockservice/lock_table_local.go:656: A transaction holds 17 exact points with a 16-key ordinary capacity, then requests an ordinary range covering two of those points.
Impact: The owner rejects the range with ErrLockNeedUpgrade after deleting the two previously granted point locks. A competing transaction can acquire an exclusive lock on a point that should remain protected until the original transaction ends.
Evidence: At pkg/lockservice/lock_table_local.go:1073, the merge deletes the old entries and moves their waiters before lockAdded checks capacity at line 1081. The two-CN probe confirmed that the range succeeded with 16 points. With 17 points, the range was rejected and a competing writer acquired a previously held point before the original transaction unlocked. Validate the replacement before committing the key and waiter changes. See ../attempt-1/partial-range.jsonl and ../attempt-1/checks/1795517495511950033-2.json.
Validation:
-
Verified the frozen checkout, patch, whitespace, native-input ledger, and all 31 discussion entries. Matched 11 terminal receipts to retained logs in validation-reconciliation.json.
-
The full lock-service and transaction-client packages passed under the race detector. The accepted remote range after exact points passed 100 race repetitions. Focused frontend, planner, compiler, lock-operator, and protobuf checks passed.
-
The ordinary metadata SQL regression passed and verified both committed updates. Frozen CI reported passing unit tests, static analysis, and the proxy and pessimistic multi-CN BVT lanes.
Limitations:
-
The rejected-range failure was verified through the real two-CN lock service. Its SQL impact was assessed from source.
-
Local ALTER, wide-grant, and full-restore SQL validation remained incomplete after bounded checks and HAKeeper connection timeouts. Production-scale behavior at default lock limits was unmeasured.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed cf9854060bb4f0a53d7520d595605fcc928b46cd against 4.2-dev at 9ed1645371c63ad2c417022de9e4d56db8697ecc. Original issue and acceptance criteria
- [P1] Preserve exact point locks when a partial range is rejected (
pkg/lockservice/lock_table_local.go:656). Withmax-fixed-slice-size=16, let a transaction acquire 17 exact shared points on one table, then request an ordinary shared range covering exactly two of those points. The owner commits the merge at line 1073, deleting both point locks and moving their waiters. The append at line 1081 then rejects the two range endpoints because 15 retained keys plus two endpoints exceed the limit. The owner returnsErrLockNeedUpgradebefore installing the replacement, so a competing transaction can acquire an exclusive lock on either removed point while the original transaction is still open. The patch makes this state reachable by allowing exact grants to exceed one segment. On the base, a transaction holding at most 16 keys can replace two points with two endpoints within the limit. Check the replacement capacity before deleting held points or moving their waiters. The exact-head two-CN probe reported the premature exclusive acquisition and a passing 16-point control. Exact-head probe
The previous review's caller-side failure is addressed. Once the caller records an exact request for the table, it also uses segmented bookkeeping for a subsequent accepted ordinary range. TestRemoteRangeAfterExactRows covers this sequence at and above the segment limit. The supplied discussion has no explicit author reply to that review or its inline thread. The earlier fixture-size suggestion is addressed by reducing the wide SQL case to 17 recipients. Previous review · Previous fixture feedback
The earlier fixes remain in place for minimum-budget DROP, foreign shared ranges, standalone wide named grants, ordinary DML metadata admission, restore proxy routing, and preservation of lock mode on the wire. The author explicitly replied to those findings. Minimum-budget DROP reply · Range and standalone capacity reply · Metadata, proxy, and wire replies
The supplied exact-head CI snapshot records 29 completed checks. Fourteen passed, 13 were skipped, two were neutral, and none failed. CI Required passed. The complete diff matched the snapshot after normalizing Git's abbreviated blob hashes. git diff --check and the Loom artifact check passed. I skipped local runtime tests because the lock-owner failure is confirmed by source tracing and the exact-head two-CN probe. The rejected partial range was verified at the lock-service boundary. CI Required
|
mo-bot review · Commit: New discussion was assessed; the previous review remains unchanged. |
Stage the retained keys and replacement endpoints under the transaction lock before removing owner entries or committing waiter transfers. Keep an active waiter deadline when releasing only a merge reference. Cover accepted and rejected partial ranges across CNs, retained snapshots, and waiter ownership through retry and unlock.
Keep exact-row segment tracking in successful and uncertain remote lock paths. Retain the target branch's close fence, cleanup deadlines, and live-only fixed-slice references. Cover fenced grants across the segment boundary with and without their RPC reply.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 5bd8ef1ba2db45379a944460cf5f2126920aa118
Assessment: approve
The earlier rejected-range lock-loss finding is resolved: the owner admits the replacement before changing held locks or waiter queues. The fix reuses the existing lock owner, with segmented key retention for wide named grants and consistent routing for maintenance transactions. No actionable correctness or design finding remains.
Model: gpt-6.1-terra / max
Session: 01a215d1-7203-74e1-813a-2513cddd0c27 · slot 0 · generation 15
Validation:
-
All five current-head embedded SQL integration tests passed, covering minimum-budget DROP and restore, unrelated and targeted DROP during ALTER, grants beyond one segment, ordinary metadata locking, and remote proxy restore. Receipt: checks/1795671917368844604-2.json; log: sql-integration.log.
-
The lock-service and transaction-client packages passed under the race detector. Receipt: checks/1795672190656904548-2.json; log: owner-race.jsonl.
-
The partial-range regression passed 100 race-instrumented repetitions. Receipt: checks/1795672020920642769-2.json; log: range-stress.jsonl.
-
Focused frontend, planner, compiler, lock-operator, transaction-option, and wire tests passed. Receipt: checks/1795671969317387048-2.json; log: focused.log.
-
Preflight, generated descriptor comparison, and git diff --check passed. The successful receipts and retained logs are indexed in validation-reconciliation.json.
Limitations:
-
Performance on large production catalogs at the default lock limits was not measured.
-
The separate ACCOUNT ALL and concurrent account-creation race remains tracked by issue 32941.
iamlinjunhong
left a comment
There was a problem hiding this comment.
Reviewed 5bd8ef1ba2db45379a944460cf5f2126920aa118 against 4.2-dev at 86a86738e55a032f2a7f3cc3b3b9afe9e290332f for the named publication and DROP ACCOUNT behavior in #32986. No remaining findings.
- The owner now admits the replacement range before deleting held points or committing the waiter transfer. A capacity rejection leaves the original locks and waiters intact. The regression covers 16 held points, rejection with 17 points, and unlock after a successful covering range. The frozen discussion contains no explicit author reply to the previous review. Previous review
- The remote caller retains segmented bookkeeping for subsequent ordinary locks after an exact request. The same recording path handles grants fenced during close and requests with lost replies. The earlier fixes for minimum-limit DROP, ordinary metadata admission, restore proxy routing, and RPC lock mode remain in place. Remote bookkeeping review · Earlier author replies
The exact-head CI snapshot shows 15 successful, 16 skipped, and 2 neutral checks out of 33, with no failures or pending checks. CI Required, Ubuntu x86 unit tests, static analysis, and the pessimistic multi-CN and proxy BVT jobs succeeded. This review used the frozen CI results and source inspection. Local tests were skipped because the reviewed paths were traceable in source and the snapshot already included the relevant CI suites. CI run
✅ Merged into
|
What type of PR is this?
Which issue does this fix?
Fixes #32986. Follow-up to #32937 on
4.2-dev.Change
A named publication pins each immutable subscriber ID before writing grants. On 4.2 the optimizer could widen even a single-recipient locking read to the whole account table. The matching DROP has two opportunities to widen the lock as well.
FOR SHAREread and existence check. For named recipients, sort the final IDs and batch the reads up to the CN's configured row-lock count. A missing ID aborts the statement with the existing retry error.mo_catalog.mo_accounttarget. Plan copies and remote pipeline operators preserve it. That target rejects a covering range or lock-service escalation. Its unique index and pre-pipeline metadata locks keep their separate policies.mo_accountDELETE during DROP. The existingACCOUNT ALLpath still uses its previous locking policy. The separate new-account race is tracked in [Bug]: PubSub: concurrent CREATE ACCOUNT and CREATE PUBLICATION ACCOUNT ALL leave the new account unable to subscribe #32941.Validation
Reproduced the review report at
944a75da6f. With one CN,max-row-lock-count = 1and no concurrent publication, the final account DELETE returned 20707. On the parent53b3bc7c95, the direct DROP succeeded but a cluster restore removing a post-snapshot account failed with 20105 on a shared metadata range.Added
TestDropAccountWithMinimumRowLockCount. At the same minimum, direct DROP and RESTORE CLUSTER succeed, the post-snapshot account is absent and the test table contains its original value. In a separate two-CN account snapshot test at the same minimum, the restored account had one active grant on its new ID, zero on its old ID, and read the live published value 10.Two CNs, one TN, real MySQL DDL, row-lock threshold 16. With 1 and 17 named recipients, the unrelated DROP commits while ALTER is still held at its publication write. The wide case places the unrelated account inside the target ID range. A targeted DROP waits, then leaves zero grants for its old ID. Normal and Go race builds pass. Restoring the five production files from the unpatched branch head makes the same wide case fail at the unrelated DROP's 30-second deadline.
The existing drop/grant race and SHOW PUBLICATIONS SQL tests pass under
-race. Recreating the same name gives it a different ID and zero inherited grants. An unaffected subscription reads the source row.Account snapshot restore recreates ID 1 as 10001 with one active grant and reads the live source value 10. A separate optimistic CN/TN run covers ordinary DML, CREATE/ALTER publication, DROP and the surviving subscription (value 7).
Full frontend and lock operator packages pass under
-race. Five focused planner tests pass. Changed packages pass golangci-lint.Checked main PR fix(frontend): prevent publication grants from recreating dropped subscriber IDs #32936 at
7cd54cda1c. Its existing CREATE lock-scope and stale-grant tests pass under-race. During actual ALTER, the transaction holds exactly 1 or 17 shared point locks onmo_account, matching every resolved ID.In the two-CN range regression, an ordinary transaction holds a shared range before ALTER starts. ALTER waits for it, an unrelated DROP then completes while ALTER is gated at its publication write, and a targeted DROP waits for ALTER.
With a row-lock budget of 16 and a fixed-slice limit of 128, CREATE PUBLICATION grants all 129 named recipients in one transaction. After commit the other CN drops the first and last recipients and reads 127 active grants.
Lock and ForwardLock carry the requested mode unchanged. Exact-row locking is a separate flag enforced at the owner. Restore and task-storage transactions use the remote owner from the first request on a proxied table through unlock. The transaction option travels with distributed execution and is cleared on transaction reuse. Normal transactions retain their existing proxy routing safeguards.
On the reviewed commit (
c891af160c), a 17-table UPDATE failed with MySQL 20105 when a concurrent update held five overlapping metadata keys. The same SQL now commits both transactions and reads both updated values back. The minimum-budget DROP and cluster restore also pass with CDC cleanup enabled.On the same reviewed commit, two fresh transactions each returned ErrTxnNeedRetry after an ordinary shared request followed by an exact request on the same remote row. The full SQL restore encountered an earlier multi-row proxy failure (20101). On the fix, with CN0 owning mo_account and the proxy enabled on CN1, RESTORE CLUSTER on CN1 restored the ACCOUNT ALL and named publications, with an active grant from each for the subscriber.
Wire tests cover Lock and ForwardLock with both lock modes and both exactness settings. Transaction tests exercise remote snapshots and reuse.
The default threshold of 20,000 did not reproduce the original wait on the small test catalog. Large production catalogs and mixed-version clusters were not measured.