Repository navigation
fix(lockservice): fence stale binds by allocator epoch (#24906) - #25819
iamlinjunhong wants to merge 4 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? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes: late NewBind responses can republish a bind from a superseded allocator after the new allocator has already purged it.
Reproduced locally with this ordering: cache remote bind from A0 → observe A1 (version may regress) and purge the table → deliver an in-flight NewBind from A0 whose allocator ID matches the request bind. The table is recreated with AllocatorID=A0, violating the core fence invariant and allowing new transactions to use a bind the current TN allocator no longer recognizes. The same bypass exists in the keeper response path.
Please route these asynchronous NewBind publications through allocator-state validation (or refresh from the current allocator), and add race regressions for both paths.
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? |
1 similar comment
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? |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No blocking correctness, concurrency, compatibility, or resource-handling regressions found. Verified the allocator-epoch fencing paths and ran go test ./pkg/lockservice -count=1.
aunjgr
left a comment
There was a problem hiding this comment.
Reviewed head efa6161. This is a clean 4.1-dev backport of the already-merged allocator-epoch fencing and late-bind rejection fixes. The ownership, cancellation, refresh-failure, and exact-bind invalidation paths retain the upstream behavior. No remaining blockers found.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
The allocator fencing works for fully upgraded peers, and both the full lockservice suite and focused race tests pass. However, the original stale-bind-until-COMMIT failure remains reachable during a mixed-version rolling upgrade.
P1 - Fence legacy binds when allocator identity first appears (pkg/lockservice/service.go:795)
A new CN can cache binds from an old TN whose responses contain no allocator metadata, leaving lastAllocatorID/Version and each bind's AllocatorID empty. If that TN is then upgraded/restarted with a regressed or equal epoch, this condition sets allocatorChanged=false because no previous allocator state was recorded. The purge consequently falls back to bind.Version < observed.version, retains the legacy binds, and then records the new allocator ID; subsequent keepalives hit the same-allocator fast path and never reconsider them. If another table re-registers the CN first, keepalive is OK=true, reproducing the original behavior where the stale bind survives until commit validation fails. Treat the first non-empty allocator ID as an identity boundary for already-cached empty-ID binds, and cover old-TN → new-TN transition with a regressed epoch.
fixed |
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
One P1 mixed-version fencing gap remains.
P1 - Observe allocator identity before filtering an otherwise equal legacy bind (pkg/lockservice/lock_table_keeper.go:236)
A successful GetBind response is passed to allocator fencing only when newBind.Changed(bind). Changed intentionally treats an empty AllocatorID as compatible with a non-empty one, so an old-TN bind and an upgraded allocator's equal-version, same-owner bind compare unchanged. The new allocator identity is then discarded: legacy tables are not purged and active transactions are not fenced. Because allocator validation uses the same compatibility comparison, such a transaction can also pass commit validation before the next keepalive. The identical gate exists in remoteLockTable refresh paths. Validate allocator state on every successful GetBind before using structural equality to decide publication, and test equal-epoch old-TN→new-TN refreshes with an active transaction.
gouhongshen
left a comment
There was a problem hiding this comment.
Codex automated review
No actionable regressions found at verified HEAD 15bf309. Prior review blockers are resolved: stale responses are fenced before publication, and first allocator identity observation purges legacy empty-ID binds. Protocol changes are additive and rolling compatibility is handled explicitly. Concurrency, cleanup, unhappy paths, and focused coverage are coherent. go test ./pkg/lockservice -count=1 passed in 584.972s; current CI checks are green and git diff --check is clean.
fix(lockservice): fence stale binds by allocator epoch
Approved by: @aptend, @XuPeng-SH, @aunjgr
What type of PR is this?
Which issue(s) this PR fixes:
issue #24896
What this PR does / why we need it:
fix(lockservice): fence stale binds by allocator epoch (#24906)