Skip to content

fix(lockservice): keep owner discovery absence non-fatal - #28649

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/fix-lockservice-owner-discovery
Sep 11, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/fix-lockservice-owner-discovery

Conversation

@XuPeng-SH

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:

Related issue #27707 (follow-up to #28474; startup failure observed while validating #28459)

What this PR does / why we need it:

The lockservice commit cleaner used a raw HAKeeper membership miss as proof
that a CN was inactive. During CN/HAKeeper startup ordering, the allocator can
already have admitted a bind while the first membership snapshot is not yet
published. The cleaner then installed inactiveService, and the next commit
returned cannot commit an orphan transaction on invalid cn even though the CN
was live. This is the root cause of the apparently flaky ArrowLoad UT failure;
#28459 itself does not touch this lifecycle code.

This change separates discovery uncertainty from retirement evidence:

  • a missing owner is recorded only in a cleanup-only retention marker and never
    fences Valid; positive admission, bind keepalive, an authoritative probe,
    or Resume clears that marker;
  • exact allocator-bind retirement still establishes an admission fence before
    deleting the bind, including generation zero;
  • timeout retirement snapshots controller identity and recovery epoch, so a
    stale validation cannot remove or re-fence a bind after Resume, controller
    replacement, or epoch saturation;
  • the cleanup-only marker gives controllers with no allocator bind a bounded
    expiry path, while existing inactive fences and orphan tombstones remain
    authoritative.

Test plan

  • GOTMPDIR=/home/xupeng/go-tmp ./.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s -run '^TestArrowLoadRolloutRollbackDrain$' ./pkg/tests/arrowload
  • GOTMPDIR=/home/xupeng/go-tmp ./.agents/skills/mo-dev/scripts/mo-cgo-test -short -count=1 -timeout=360s ./pkg/lockservice
  • GOTMPDIR=/home/xupeng/go-tmp ./.agents/skills/mo-dev/scripts/mo-cgo-test -short -race -count=1 -timeout=420s ./pkg/lockservice
  • lifecycle and unhappy-path selections (absent owner, pending/live bind,
    orphan/fence preservation, cleanup expiry, Resume interleaving, controller
    creation/replacement, and epoch saturation) passed with -race -count=100;
  • golangci-lint run -c .golangci.yml ./pkg/lockservice/... passed with 0
    issues; git diff --check passed.

@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 →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reviewed exact head 9099ade against main a6a493a. No concrete merge-blocking issue found. COMMENT only for this self-authored PR.

The important distinction is implemented at the cleaner boundary, not by making a lock RPC silently succeed. Missing raw membership leaves GetActiveTxn unknown: no active-transaction result is manufactured, no lock is released, and the existing orphan tombstone remains protected. Valid still validates supplied bind versions and checks authoritative inactive/orphan state. Positive admission/keepalive/probe clears only the new cleanup-only marker, not an existing inactive fence.

I traced the retirement race separately. Exact bind retirement now establishes the service fence before bind removal under allocator serialization, including generation zero. Timeout evidence carries bind identity/keepalive generation plus controller identity/recovery epoch. Resume is excluded by ctlMu while the evidence is checked and the fence installed; creation/replacement and saturated recovery epochs reject stale retirement. An admission already in flight remains covered by the existing commit-controller protection. The new critical sections contain no RPC; lock acquisition paths examined do not introduce an opposite simultaneous lock order.

For absence cleanup, LoadOrStore preserves the first-observed timestamp instead of extending retention every sweep. Snapshot/controller/epoch/state-generation checks protect replacement and fresh transaction state. Both currently present markers must expire before expiry cleanup, and inflight commits/persistent fences retain their independent protections. Marker-only entries remain in the sweep inventory even after an empty controller is removed, permitting later expiry. This is retention-bounded per observed service, not a fixed global entry-count cap.

The normal admission/keepalive path adds a sync.Map lookup and takes the absence mutex only when a marker is present. No new goroutine, network retry loop, wire field or configuration is added. Unknown membership still rechecks next sweep; cancellation and the existing bounded connection-error recovery remain distinct from absence.

Tests cover pending/live owners, no spurious admission fence, preserved prior fences and orphan state, positive evidence, cleanup-only expiry, generation-zero retirement, Resume during validation, controller creation/replacement and epoch saturation. These are appropriate deterministic counterexamples to the changed transitions. No supplementary test preference is treated as a blocker.

Evidence/limits: full three-file diff, PR discussion/reviews, exact-head admission/commit cleanup and timeout-retirement consumers inspected; live head/base rechecked before submission. The reported lockservice race/stress, Arrow rollout and lint results are author evidence; I did not independently rerun native tests or a real restart/HAKeeper-failure experiment, and did not wait for CI.

@XuPeng-SH
XuPeng-SH merged commit e7d46d6 into matrixorigin:main Sep 11, 2026
29 checks passed
@XuPeng-SH
XuPeng-SH deleted the codex/fix-lockservice-owner-discovery branch September 11, 2026 01:56
XuPeng-SH added a commit that referenced this pull request Sep 11, 2026
## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

Related: #26519

## What this PR does / why we need it:

Arrow's default BVT and distributed fanout tests previously started
separate embedded clusters with the same default configuration. Run
their existing assertions in one 2-CN BVT cluster, using a separate
database and session for fanout and keeping restart persistence last.
This removes one cluster lifecycle without adding parallel tests or
changing production behavior.

Rebased onto main at cd8e8d9. Remove this PR's earlier
owner-readiness polling workaround because the production
owner-discovery fix is now on main through #28649. Register cleanup for
a nonnil cluster before asserting startup success, and update the
documented test selectors.

## Validation

- Full Arrow package, normal: passed, 84.690s.
- Same-process BVT repetition (`-count=2`): passed, 35.165s total.
- `golangci-lint` on the Arrow package: 0 issues.
- Full Arrow package with `-race`: passed, 92.297s.
- Exact BVT with `-race -count=1`: passed, 33.383s (adaptive 30s budget
selected one repetition from the measured 22.35s BVT).
- GPT-6 medium reviewed the implementation and the final validation
evidence.

On this host with runtime temporary data on NVMe, the main-version
separate fixtures took 32.080s combined; the consolidated BVT took
17.66s and 17.32s in two sequential repetitions. These are local
samples, not a prediction of whole-CI savings. The initial baseline
attempt failed because the host's `/tmp` was full; its result is
excluded from timing comparison, and both sides were rerun using
disk-backed temporary data.

The existing LocalMinIO subtest skipped because the external `minio`
binary is unavailable. This test-only change does not repair the
separate close-error/admission-retention failure observed in the
previous CI run and does not claim to resolve its 70-minute global
timeout.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#28649)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related issue matrixorigin#27707 (follow-up to matrixorigin#28474; startup failure observed
while validating matrixorigin#28459)

## What this PR does / why we need it:

The lockservice commit cleaner used a raw HAKeeper membership miss as
proof
that a CN was inactive. During CN/HAKeeper startup ordering, the
allocator can
already have admitted a bind while the first membership snapshot is not
yet
published. The cleaner then installed `inactiveService`, and the next
commit
returned `cannot commit an orphan transaction on invalid cn` even though
the CN
was live. This is the root cause of the apparently flaky ArrowLoad UT
failure;
matrixorigin#28459 itself does not touch this lifecycle code.

This change separates discovery uncertainty from retirement evidence:

* a missing owner is recorded only in a cleanup-only retention marker
and never
fences `Valid`; positive admission, bind keepalive, an authoritative
probe,
  or `Resume` clears that marker;
* exact allocator-bind retirement still establishes an admission fence
before
  deleting the bind, including generation zero;
* timeout retirement snapshots controller identity and recovery epoch,
so a
stale validation cannot remove or re-fence a bind after `Resume`,
controller
  replacement, or epoch saturation;
* the cleanup-only marker gives controllers with no allocator bind a
bounded
expiry path, while existing inactive fences and orphan tombstones remain
  authoritative.

### Test plan

* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s
-run '^TestArrowLoadRolloutRollbackDrain$' ./pkg/tests/arrowload`
* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -short -count=1
-timeout=360s ./pkg/lockservice`
* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -short -race -count=1
-timeout=420s ./pkg/lockservice`
* lifecycle and unhappy-path selections (absent owner, pending/live
bind,
orphan/fence preservation, cleanup expiry, Resume interleaving,
controller
creation/replacement, and epoch saturation) passed with `-race
-count=100`;
* `golangci-lint run -c .golangci.yml ./pkg/lockservice/...` passed with
0
  issues; `git diff --check` passed.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8648)

## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

Related: matrixorigin#26519

## What this PR does / why we need it:

Arrow's default BVT and distributed fanout tests previously started
separate embedded clusters with the same default configuration. Run
their existing assertions in one 2-CN BVT cluster, using a separate
database and session for fanout and keeping restart persistence last.
This removes one cluster lifecycle without adding parallel tests or
changing production behavior.

Rebased onto main at cd8e8d9. Remove this PR's earlier
owner-readiness polling workaround because the production
owner-discovery fix is now on main through matrixorigin#28649. Register cleanup for
a nonnil cluster before asserting startup success, and update the
documented test selectors.

## Validation

- Full Arrow package, normal: passed, 84.690s.
- Same-process BVT repetition (`-count=2`): passed, 35.165s total.
- `golangci-lint` on the Arrow package: 0 issues.
- Full Arrow package with `-race`: passed, 92.297s.
- Exact BVT with `-race -count=1`: passed, 33.383s (adaptive 30s budget
selected one repetition from the measured 22.35s BVT).
- GPT-6 medium reviewed the implementation and the final validation
evidence.

On this host with runtime temporary data on NVMe, the main-version
separate fixtures took 32.080s combined; the consolidated BVT took
17.66s and 17.32s in two sequential repetitions. These are local
samples, not a prediction of whole-CI savings. The initial baseline
attempt failed because the host's `/tmp` was full; its result is
excluded from timing comparison, and both sides were rerun using
disk-backed temporary data.

The existing LocalMinIO subtest skipped because the external `minio`
binary is unavailable. This test-only change does not repair the
separate close-error/admission-retention failure observed in the
previous CI run and does not claim to resolve its 70-minute global
timeout.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#28649)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related issue matrixorigin#27707 (follow-up to matrixorigin#28474; startup failure observed
while validating matrixorigin#28459)

## What this PR does / why we need it:

The lockservice commit cleaner used a raw HAKeeper membership miss as
proof
that a CN was inactive. During CN/HAKeeper startup ordering, the
allocator can
already have admitted a bind while the first membership snapshot is not
yet
published. The cleaner then installed `inactiveService`, and the next
commit
returned `cannot commit an orphan transaction on invalid cn` even though
the CN
was live. This is the root cause of the apparently flaky ArrowLoad UT
failure;
matrixorigin#28459 itself does not touch this lifecycle code.

This change separates discovery uncertainty from retirement evidence:

* a missing owner is recorded only in a cleanup-only retention marker
and never
fences `Valid`; positive admission, bind keepalive, an authoritative
probe,
  or `Resume` clears that marker;
* exact allocator-bind retirement still establishes an admission fence
before
  deleting the bind, including generation zero;
* timeout retirement snapshots controller identity and recovery epoch,
so a
stale validation cannot remove or re-fence a bind after `Resume`,
controller
  replacement, or epoch saturation;
* the cleanup-only marker gives controllers with no allocator bind a
bounded
expiry path, while existing inactive fences and orphan tombstones remain
  authoritative.

### Test plan

* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s
-run '^TestArrowLoadRolloutRollbackDrain$' ./pkg/tests/arrowload`
* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -short -count=1
-timeout=360s ./pkg/lockservice`
* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -short -race -count=1
-timeout=420s ./pkg/lockservice`
* lifecycle and unhappy-path selections (absent owner, pending/live
bind,
orphan/fence preservation, cleanup expiry, Resume interleaving,
controller
creation/replacement, and epoch saturation) passed with `-race
-count=100`;
* `golangci-lint run -c .golangci.yml ./pkg/lockservice/...` passed with
0
  issues; `git diff --check` passed.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8648)

## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

Related: matrixorigin#26519

## What this PR does / why we need it:

Arrow's default BVT and distributed fanout tests previously started
separate embedded clusters with the same default configuration. Run
their existing assertions in one 2-CN BVT cluster, using a separate
database and session for fanout and keeping restart persistence last.
This removes one cluster lifecycle without adding parallel tests or
changing production behavior.

Rebased onto main at cd8e8d9. Remove this PR's earlier
owner-readiness polling workaround because the production
owner-discovery fix is now on main through matrixorigin#28649. Register cleanup for
a nonnil cluster before asserting startup success, and update the
documented test selectors.

## Validation

- Full Arrow package, normal: passed, 84.690s.
- Same-process BVT repetition (`-count=2`): passed, 35.165s total.
- `golangci-lint` on the Arrow package: 0 issues.
- Full Arrow package with `-race`: passed, 92.297s.
- Exact BVT with `-race -count=1`: passed, 33.383s (adaptive 30s budget
selected one repetition from the measured 22.35s BVT).
- GPT-6 medium reviewed the implementation and the final validation
evidence.

On this host with runtime temporary data on NVMe, the main-version
separate fixtures took 32.080s combined; the consolidated BVT took
17.66s and 17.32s in two sequential repetitions. These are local
samples, not a prediction of whole-CI savings. The initial baseline
attempt failed because the host's `/tmp` was full; its result is
excluded from timing comparison, and both sides were rerun using
disk-backed temporary data.

The existing LocalMinIO subtest skipped because the external `minio`
binary is unavailable. This test-only change does not repair the
separate close-error/admission-retention failure observed in the
previous CI run and does not claim to resolve its 70-minute global
timeout.
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…n#28649)

## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Related issue matrixorigin#27707 (follow-up to matrixorigin#28474; startup failure observed
while validating matrixorigin#28459)

## What this PR does / why we need it:

The lockservice commit cleaner used a raw HAKeeper membership miss as
proof
that a CN was inactive. During CN/HAKeeper startup ordering, the
allocator can
already have admitted a bind while the first membership snapshot is not
yet
published. The cleaner then installed `inactiveService`, and the next
commit
returned `cannot commit an orphan transaction on invalid cn` even though
the CN
was live. This is the root cause of the apparently flaky ArrowLoad UT
failure;
matrixorigin#28459 itself does not touch this lifecycle code.

This change separates discovery uncertainty from retirement evidence:

* a missing owner is recorded only in a cleanup-only retention marker
and never
fences `Valid`; positive admission, bind keepalive, an authoritative
probe,
  or `Resume` clears that marker;
* exact allocator-bind retirement still establishes an admission fence
before
  deleting the bind, including generation zero;
* timeout retirement snapshots controller identity and recovery epoch,
so a
stale validation cannot remove or re-fence a bind after `Resume`,
controller
  replacement, or epoch saturation;
* the cleanup-only marker gives controllers with no allocator bind a
bounded
expiry path, while existing inactive fences and orphan tombstones remain
  authoritative.

### Test plan

* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -v -count=1 -timeout=180s
-run '^TestArrowLoadRolloutRollbackDrain$' ./pkg/tests/arrowload`
* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -short -count=1
-timeout=360s ./pkg/lockservice`
* `GOTMPDIR=/home/xupeng/go-tmp
./.agents/skills/mo-dev/scripts/mo-cgo-test -short -race -count=1
-timeout=420s ./pkg/lockservice`
* lifecycle and unhappy-path selections (absent owner, pending/live
bind,
orphan/fence preservation, cleanup expiry, Resume interleaving,
controller
creation/replacement, and epoch saturation) passed with `-race
-count=100`;
* `golangci-lint run -c .golangci.yml ./pkg/lockservice/...` passed with
0
  issues; `git diff --check` passed.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…8648)

## What type of PR is this?

- [x] Improvement
- [x] Test and CI

## Which issue(s) this PR fixes:

Related: matrixorigin#26519

## What this PR does / why we need it:

Arrow's default BVT and distributed fanout tests previously started
separate embedded clusters with the same default configuration. Run
their existing assertions in one 2-CN BVT cluster, using a separate
database and session for fanout and keeping restart persistence last.
This removes one cluster lifecycle without adding parallel tests or
changing production behavior.

Rebased onto main at cd8e8d9. Remove this PR's earlier
owner-readiness polling workaround because the production
owner-discovery fix is now on main through matrixorigin#28649. Register cleanup for
a nonnil cluster before asserting startup success, and update the
documented test selectors.

## Validation

- Full Arrow package, normal: passed, 84.690s.
- Same-process BVT repetition (`-count=2`): passed, 35.165s total.
- `golangci-lint` on the Arrow package: 0 issues.
- Full Arrow package with `-race`: passed, 92.297s.
- Exact BVT with `-race -count=1`: passed, 33.383s (adaptive 30s budget
selected one repetition from the measured 22.35s BVT).
- GPT-6 medium reviewed the implementation and the final validation
evidence.

On this host with runtime temporary data on NVMe, the main-version
separate fixtures took 32.080s combined; the consolidated BVT took
17.66s and 17.32s in two sequential repetitions. These are local
samples, not a prediction of whole-CI savings. The initial baseline
attempt failed because the host's `/tmp` was full; its result is
excluded from timing comparison, and both sides were rerun using
disk-backed temporary data.

The existing LocalMinIO subtest skipped because the external `minio`
binary is unavailable. This test-only change does not repair the
separate close-error/admission-retention failure observed in the
previous CI run and does not claim to resolve its 70-minute global
timeout.

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

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants