Skip to content

fix(lockservice): fence stale binds by allocator epoch - #24906

Merged
mergify[bot] merged 17 commits into
matrixorigin:mainfrom
iamlinjunhong:m-24896
Jul 4, 2026
Merged

mergify[bot] merged 17 commits into
matrixorigin:mainfrom
iamlinjunhong:m-24896

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #24896

What this PR does / why we need it:

fix(lockservice): fence stale binds by allocator epoch

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Jun 9, 2026

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Result

Approved. I did not find any blocking issues in this PR.

What I Checked

  • GetBind and KeepLockTableBind propagate the allocator epoch to CN.
  • CN stale-bind purge follows the existing LockTable.Version semantics: cached binds with Version < observed allocator epoch are stale allocator state.
  • main-branch bind-change handling was reviewed against the epoch purge path, including waiter cleanup and commit-side bind validation.
  • The added tests cover get-bind refresh, keepalive failure/epoch refresh, concurrent observation, remote/proxy bind purge, and waiter cleanup.

Local Verification

git diff --check origin/main...HEAD
go test ./pkg/lockservice -run 'Test(CommitDetectsStaleLocalBindAfterAllocatorRestart|AllocatorVersionZeroKeepsLocalBinds|AllocatorObserverDoesNotPurgeSameEpochBindVersions|GetBindAllowsRegressedAllocatorVersionWithoutPurging|KeepaliveEpochPurgeKeepsGroupMovePop|AllocatorObserverPurgesRemoteAndProxyLockTables|AllocatorObserverConcurrentKeepaliveAndGetBind|AllocatorObserverCloseWaitersOnStaleLocalBind)$'
timeout 180s go test ./pkg/lockservice

Note: the full go test ./pkg/lockservice hit the 180s local timeout without output. The PR-specific test set passed locally, and CI is green.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-checked the latest head. I do not see a new high-confidence correctness bug to block on, and the unit coverage is already much stronger, but with a lockservice fix this concurrency-heavy I still think a few unhappy-path tests are missing before I am comfortable approving.\n\nThe main gaps I would still ask to close are:\n\n1. Repeated allocator restarts / superseded-ID accumulation\n The new fencing now relies on tracking superseded allocator identities, but I did not see a focused test that drives 3+ sequential allocator replacements and proves both correctness and bounded behavior over repeated generations.\n\n2. Client-side cancel before the remote lock request is actually sent\n The PR now keeps more remote-lock bookkeeping alive for later cleanup, and there is timeout coverage, but I did not find the specific unhappy path where the caller is canceled before the remote side ever received the lock request. I would like a test that proves the later unlock/close path handles that harmlessly.\n\n3. The narrow race between getLocalLockTable() and taking bindChangeMu.RLock()\n The latest code intentionally adds a second stale-bind recheck around that window. That is exactly the kind of defensive race fix that should be pinned by a test, and I did not find one that explicitly exercises a bind change in that gap.\n\nIf those concurrency-edge cases are covered, I am happy to recheck the latest head.

@iamlinjunhong

Copy link
Copy Markdown
Contributor Author

I re-checked the latest head. I do not see a new high-confidence correctness bug to block on, and the unit coverage is already much stronger, but with a lockservice fix this concurrency-heavy I still think a few unhappy-path tests are missing before I am comfortable approving.\n\nThe main gaps I would still ask to close are:\n\n1. Repeated allocator restarts / superseded-ID accumulation\n The new fencing now relies on tracking superseded allocator identities, but I did not see a focused test that drives 3+ sequential allocator replacements and proves both correctness and bounded behavior over repeated generations.\n\n2. Client-side cancel before the remote lock request is actually sent\n The PR now keeps more remote-lock bookkeeping alive for later cleanup, and there is timeout coverage, but I did not find the specific unhappy path where the caller is canceled before the remote side ever received the lock request. I would like a test that proves the later unlock/close path handles that harmlessly.\n\n3. The narrow race between getLocalLockTable() and taking bindChangeMu.RLock()\n The latest code intentionally adds a second stale-bind recheck around that window. That is exactly the kind of defensive race fix that should be pinned by a test, and I did not find one that explicitly exercises a bind change in that gap.\n\nIf those concurrency-edge cases are covered, I am happy to recheck the latest head.

fixed

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the lock service epoch fencing fix. Needs rebase — merge conflicts in hive_partition_test.go.

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The conflict in hive_partition_test.go is trivial — one-line sync.Once change. Please rebase and unblock merge.

@mergify

mergify Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-04 09:18 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-07-04 10:33 UTC · at ee6433881c318560b79a5b1d14eadf12fd73b512 · squash

This pull request spent 1 hour 14 minutes 48 seconds in the queue, including 1 hour 14 minutes 36 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • github-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants