Skip to content

fix(lockservice): recover rejected routes and quiesce departed owners - #28474

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
aptend:fix/27707-dn-inactive-expiry
Sep 10, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
aptend:fix/27707-dn-inactive-expiry

Conversation

@aptend

@aptend aptend commented Sep 9, 2026 •

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 #27707

Keep the issue open until the complete fixed image passes the field acceptance gate below; merging this PR alone is not the closure criterion.

What this PR does / why we need it:

This follow-up closes two recovery gaps left after #28115 and #28343, without weakening their transaction fences:

  • DN departed-owner recovery: check the local raw CN inventory before GetActiveTxn. If no endpoint exists, retain admission/cannot-commit fences but skip futile RPCs, backend resets and repeated missing-owner errors. Recheck membership every normal sweep, including pending-admission CNs.
  • Safe eventual expiry: preserve the first disconnect timestamp rather than extending the 24-hour retention on each failure. Cleanup validates ctl identity, recovery epoch, transaction watermark and inactive timestamp against Resume, fresh state and replacement ctl. In-flight Commit and persistent unknown-Commit fences keep their independent lifetime protection.
  • CN route recovery: a stale allocator reply can republish an invalidated exact bind after keeper detachment. New requests then reject before reaching the RPC refresh path, while the keeper correctly skips the invalidated ref. Rejection now detaches only that exact cached route, allowing subsequent discovery to fetch the converged bind. Lock, ForwardLock and RemoteLock-on-Shared-proxy use the same helper.
  • Preserved ownership: old transactions remain fenced; invalidated refs remain until their consumers release them. The helper pins ref lifetime through constant-time route detachment, preserves newer/metadata-distinct routes and same-key valid reacquisition, and closes outside mutation locks.

No wire/API/storage-format change, new retry layer/background worker, pressure-policy change or configuration-default change.

Validation:

  • Deterministic expiry/Resume/Commit/ctl-replacement and missing-membership counterexamples; negative controls fail on unfixed behavior.
  • Actual Lock and forwarded/proxied handler rejection; cancellation, new route/allocator/routing metadata, ref release/reacquisition, and close ownership controls.
  • Individual adaptive race stress, including 100 repetitions for the route and membership recovery tests.
  • Delivery integrates main f0c31cd4b8 at 56fe252fd7; CI checks out the PR head, so the current dependency graph is tested explicitly. PR head 07a73ab3e7 differs from the tested revision only in the evidence document.
  • Integrated owning package: -short -count=1 passed (86.463s); -short -race -count=1 passed (91.534s). All ten exact route/membership/expiry race tests were remeasured and repeated individually (nine at 100 repetitions, persistent-disconnect expiry at 47); all passed.
  • make build, make err-check, and repository-configured owning-package golangci passed (0 lint issues).
  • Full-repository make static-check-analysis GOLANGCI_LINT_CONCURRENCY=2 passed (exit 0): err-check, all-package molint and all-package golangci; golangci reported 0 issues under unchanged repository rules/exclusions (11m21s).
  • Additional repository license-header check passed (exit 0): 5,264 files checked, 0 invalid, 0 modified.
  • Integrated real LogService + DN + two CN processes (dn-expiry-compare-vrbvaws6, exit 0), two sequential CN replacements: both 65-second windows completed 33 SQL commits. Departed-owner DN error counters stayed [6] -> [6] and [6,6] -> [6,6]; the second transition had one transient 20702, then progress. Old uncommitted values stayed invisible, both DN fences remained, and the original locked row could be rewritten/committed and read from the other CN. All test-owned processes exited, with no CN fatal/panic. Binary SHA-256: 0d65214a27aafbfd5cc0d574b71ecdbde0ba7f9539ec82bae92986b9f256f4c8.

Limits are explicit: the real test keeps default 24-hour DN retention and 20-second cleaner cadence but uses a 10-second CN remote-lock lease. It is not a default-10-minute-lease test, a 24-hour soak or a field 15-minute acceptance run. The non-short TestIssue3288 deadline also fails at the clean investigation baseline; no assertion was weakened. Owning-package molint diagnostics match the clean baseline. Full evidence and the closure checklist are in docs/design/evidence/27707_dn_inactive_expiry.md.

Field acceptance before issue closure: use an immutable image containing the complete fix, replace both CNs with active remote-lock transactions, verify completed rollout/SQL and original-row recovery/data safety, and keep each departed owner's error counters flat for at least 15 minutes after membership convergence. This PR intentionally does not auto-close the issue.

@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

Choose a reason for hiding this comment

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

Reviewed the complete eight-file change at exact head 07a73ab, including the surrounding lock-admission, transaction-reference, allocator cleanup and RPC discovery implementations. No confirmed merge-blocking finding.

The targeted design preserves the important separation between route availability and transaction safety: rejected remote routes are detached only for the exact invalidated bind/ref generation, without releasing the old transaction's reference or re-enabling its keeper traffic. Lock, RemoteLock and ForwardLock all drop their existing transaction/read locks before entering the common transition; the ref is pinned through detachment and close occurs outside the mutation locks. A newer route or a valid same-key reacquisition is preserved. The successful admission path adds no work, and removal uses the group/table lookup rather than a table scan.

On DN, raw membership absence suppresses futile transport probes but is not treated as an authoritative negative active-transaction response. Cleanup retains first-disconnect time and revalidates ctl identity, recovery epoch, inactive timestamp and state generation after the unlocked RPC phase. Resume/fresh fencing cannot be overwritten by the old observation; in-flight commits and persistent unknown-commit fences retain their independent protections. Cancellation, repeated absence, reappearance, expiry and ctl replacement are covered by deterministic tests, alongside rejected-route consumer and exactly-once/outside-lock close controls.

Validation: exact-head CI run 34308439242 reports successful Linux UT, SCA, shared build, coverage and complementary proxy/pessimistic BVT jobs. I also reviewed the checked-in baseline/intervention, focused race and integrated two-CN replacement evidence, including its explicitly documented unsuccessful historical attempts and limits. I did not independently rerun the native package or destructive multi-process harness in this review. The shortened CN lease, two 65-second write windows and deterministic expiry tests are not a default-lease/24-hour/15-minute field soak; the documented immutable-image acceptance gate should remain a separate requirement before closing #27707.

@mergify mergify Bot added the queued label Sep 9, 2026
@mergify

mergify Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-09 05:10 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-09-09 05:13 UTC · at 07a73ab3e778b65b01d216863720c649b5f939bc

This pull request spent 3 minutes 11 seconds in the queue, with no time running CI.

Reason

Pull request #28474 has been dequeued

Queue conditions are not satisfied:

  • #changes-requested-reviews-by<=0

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@iamlinjunhong iamlinjunhong 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.

P1 — inactive markers without a commit control are never expired.

In pkg/lockservice/lock_table_allocator.go:811-812, cleanCommitStateOnce skips every snapshot with snapshot.ctl == nil before reaching applyCommitCleanup. However, the snapshot map is also populated from inactiveService, so a marker can outlive its ctl (for example, after the ctl becomes empty and is deleted, or after AddInvalidService). That marker is then never deleted at retention expiry, and Valid continues returning ErrCannotCommitOnInvalidCN for the service indefinitely. The new regression test pkg/lockservice/lock_table_allocator_recovery_test.go:306-316 explicitly creates marker-only and expects it to expire; this control flow cannot satisfy that expectation. Route ctl-less snapshots through marker expiry without issuing an RPC.

@mergify mergify Bot added dequeued and removed queued labels Sep 9, 2026
@aptend

aptend commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@iamlinjunhong I checked the P1 against the reviewed head 07a73ab3e778b65b01d216863720c649b5f939bc and reran the exact test you cited. The requested behavior is already present; there are two separate snapshot loops:

  1. Lines 807–893 perform probes. The continue at 811–812 skips only this phase for a ctl-less snapshot; it does not remove the snapshot or return from the function.
  2. Lines 898–903 independently iterate all snapshots and call applyCommitCleanup, including marker-only snapshots.
  3. In lines 925–951, absent ctl + nil snapshot ctl passes the identity guard. The marker's timestamp is revalidated, and expiry deletes the marker outside the c != nil block. If a new ctl appears after the snapshot, the identity guard deliberately preserves its state; a subsequent sweep takes a fresh snapshot.

The existing test at lines 306–316 checks both requirements: every probe must target s1 (never marker-only), and the expired marker-only entry must be absent after cleanup.

Fresh exact-head execution on September 10, with no code/test edits:

.agents/skills/mo-dev/scripts/mo-cgo-test -short -v -count=1 -timeout=120s \
  -run '^TestCleanCommitStateExpiryDoesNotRequireSuccessfulProbe$' ./pkg/lockservice
PASS: unknown, connection, negative_with_failed_reset; exit 0, package 0.297s

Same command with -race:
PASS: all three subtests; exit 0, package 1.326s

Both runs also log remove inactive service for marker-only in all three cases. The existing exact-head full CI is green; no production change is needed for this finding. Please reassess the P1 with the second cleanup loop included. I am also sending a formal re-review request, without dismissing your review or requeueing/merging the PR.

@mergify

mergify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-10 15:10 UTC · Rule: main · triggered by @aptend with the merge queue checkbox
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-10 15:25 UTC · at f2192f075c7c687f45d2dd808c5b0ead30fc5d02

This pull request spent 15 minutes 19 seconds in the queue, with no time running CI.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Reason

Pull request #28474 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit 82e3a53 into matrixorigin:main Sep 10, 2026
18 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 10, 2026
XuPeng-SH added a commit that referenced this pull request Sep 11, 2026
## 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 #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.

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
…matrixorigin#28474)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#27707

Keep the issue open until the complete fixed image passes the field
acceptance gate below; merging this PR alone is not the closure
criterion.

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

This follow-up closes two recovery gaps left after matrixorigin#28115 and matrixorigin#28343,
without weakening their transaction fences:

- **DN departed-owner recovery:** check the local raw CN inventory
before GetActiveTxn. If no endpoint exists, retain
admission/cannot-commit fences but skip futile RPCs, backend resets and
repeated missing-owner errors. Recheck membership every normal sweep,
including pending-admission CNs.
- **Safe eventual expiry:** preserve the first disconnect timestamp
rather than extending the 24-hour retention on each failure. Cleanup
validates ctl identity, recovery epoch, transaction watermark and
inactive timestamp against Resume, fresh state and replacement ctl.
In-flight Commit and persistent unknown-Commit fences keep their
independent lifetime protection.
- **CN route recovery:** a stale allocator reply can republish an
invalidated exact bind after keeper detachment. New requests then reject
before reaching the RPC refresh path, while the keeper correctly skips
the invalidated ref. Rejection now detaches only that exact cached
route, allowing subsequent discovery to fetch the converged bind. Lock,
ForwardLock and RemoteLock-on-Shared-proxy use the same helper.
- **Preserved ownership:** old transactions remain fenced; invalidated
refs remain until their consumers release them. The helper pins ref
lifetime through constant-time route detachment, preserves
newer/metadata-distinct routes and same-key valid reacquisition, and
closes outside mutation locks.

No wire/API/storage-format change, new retry layer/background worker,
pressure-policy change or configuration-default change.

Validation:

- Deterministic expiry/Resume/Commit/ctl-replacement and
missing-membership counterexamples; negative controls fail on unfixed
behavior.
- Actual Lock and forwarded/proxied handler rejection; cancellation, new
route/allocator/routing metadata, ref release/reacquisition, and close
ownership controls.
- Individual adaptive race stress, including 100 repetitions for the
route and membership recovery tests.
- Delivery integrates main `f0c31cd4b8` at `56fe252fd7`; CI checks out
the PR head, so the current dependency graph is tested explicitly. PR
head `07a73ab3e7` differs from the tested revision only in the evidence
document.
- Integrated owning package: `-short -count=1` passed (86.463s); `-short
-race -count=1` passed (91.534s). All ten exact route/membership/expiry
race tests were remeasured and repeated individually (nine at 100
repetitions, persistent-disconnect expiry at 47); all passed.
- `make build`, `make err-check`, and repository-configured
owning-package golangci passed (0 lint issues).
- Full-repository `make static-check-analysis
GOLANGCI_LINT_CONCURRENCY=2` passed (exit 0): err-check, all-package
molint and all-package golangci; golangci reported 0 issues under
unchanged repository rules/exclusions (11m21s).
- Additional repository license-header check passed (exit 0): 5,264
files checked, 0 invalid, 0 modified.
- Integrated real LogService + DN + two CN processes
(`dn-expiry-compare-vrbvaws6`, exit 0), two sequential CN replacements:
both 65-second windows completed 33 SQL commits. Departed-owner DN error
counters stayed `[6] -> [6]` and `[6,6] -> [6,6]`; the second transition
had one transient 20702, then progress. Old uncommitted values stayed
invisible, both DN fences remained, and the original locked row could be
rewritten/committed and read from the other CN. All test-owned processes
exited, with no CN fatal/panic. Binary SHA-256:
`0d65214a27aafbfd5cc0d574b71ecdbde0ba7f9539ec82bae92986b9f256f4c8`.

Limits are explicit: the real test keeps default 24-hour DN retention
and 20-second cleaner cadence but uses a 10-second CN remote-lock lease.
It is not a default-10-minute-lease test, a 24-hour soak or a field
15-minute acceptance run. The non-short `TestIssue3288` deadline also
fails at the clean investigation baseline; no assertion was weakened.
Owning-package molint diagnostics match the clean baseline. Full
evidence and the closure checklist are in
`docs/design/evidence/27707_dn_inactive_expiry.md`.

Field acceptance before issue closure: use an immutable image containing
the complete fix, replace both CNs with active remote-lock transactions,
verify completed rollout/SQL and original-row recovery/data safety, and
keep each departed owner's error counters flat for at least 15 minutes
after membership convergence. This PR intentionally does not auto-close
the issue.

---------

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
…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
…matrixorigin#28474)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#27707

Keep the issue open until the complete fixed image passes the field
acceptance gate below; merging this PR alone is not the closure
criterion.

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

This follow-up closes two recovery gaps left after matrixorigin#28115 and matrixorigin#28343,
without weakening their transaction fences:

- **DN departed-owner recovery:** check the local raw CN inventory
before GetActiveTxn. If no endpoint exists, retain
admission/cannot-commit fences but skip futile RPCs, backend resets and
repeated missing-owner errors. Recheck membership every normal sweep,
including pending-admission CNs.
- **Safe eventual expiry:** preserve the first disconnect timestamp
rather than extending the 24-hour retention on each failure. Cleanup
validates ctl identity, recovery epoch, transaction watermark and
inactive timestamp against Resume, fresh state and replacement ctl.
In-flight Commit and persistent unknown-Commit fences keep their
independent lifetime protection.
- **CN route recovery:** a stale allocator reply can republish an
invalidated exact bind after keeper detachment. New requests then reject
before reaching the RPC refresh path, while the keeper correctly skips
the invalidated ref. Rejection now detaches only that exact cached
route, allowing subsequent discovery to fetch the converged bind. Lock,
ForwardLock and RemoteLock-on-Shared-proxy use the same helper.
- **Preserved ownership:** old transactions remain fenced; invalidated
refs remain until their consumers release them. The helper pins ref
lifetime through constant-time route detachment, preserves
newer/metadata-distinct routes and same-key valid reacquisition, and
closes outside mutation locks.

No wire/API/storage-format change, new retry layer/background worker,
pressure-policy change or configuration-default change.

Validation:

- Deterministic expiry/Resume/Commit/ctl-replacement and
missing-membership counterexamples; negative controls fail on unfixed
behavior.
- Actual Lock and forwarded/proxied handler rejection; cancellation, new
route/allocator/routing metadata, ref release/reacquisition, and close
ownership controls.
- Individual adaptive race stress, including 100 repetitions for the
route and membership recovery tests.
- Delivery integrates main `f0c31cd4b8` at `56fe252fd7`; CI checks out
the PR head, so the current dependency graph is tested explicitly. PR
head `07a73ab3e7` differs from the tested revision only in the evidence
document.
- Integrated owning package: `-short -count=1` passed (86.463s); `-short
-race -count=1` passed (91.534s). All ten exact route/membership/expiry
race tests were remeasured and repeated individually (nine at 100
repetitions, persistent-disconnect expiry at 47); all passed.
- `make build`, `make err-check`, and repository-configured
owning-package golangci passed (0 lint issues).
- Full-repository `make static-check-analysis
GOLANGCI_LINT_CONCURRENCY=2` passed (exit 0): err-check, all-package
molint and all-package golangci; golangci reported 0 issues under
unchanged repository rules/exclusions (11m21s).
- Additional repository license-header check passed (exit 0): 5,264
files checked, 0 invalid, 0 modified.
- Integrated real LogService + DN + two CN processes
(`dn-expiry-compare-vrbvaws6`, exit 0), two sequential CN replacements:
both 65-second windows completed 33 SQL commits. Departed-owner DN error
counters stayed `[6] -> [6]` and `[6,6] -> [6,6]`; the second transition
had one transient 20702, then progress. Old uncommitted values stayed
invisible, both DN fences remained, and the original locked row could be
rewritten/committed and read from the other CN. All test-owned processes
exited, with no CN fatal/panic. Binary SHA-256:
`0d65214a27aafbfd5cc0d574b71ecdbde0ba7f9539ec82bae92986b9f256f4c8`.

Limits are explicit: the real test keeps default 24-hour DN retention
and 20-second cleaner cadence but uses a 10-second CN remote-lock lease.
It is not a default-10-minute-lease test, a 24-hour soak or a field
15-minute acceptance run. The non-short `TestIssue3288` deadline also
fails at the clean investigation baseline; no assertion was weakened.
Owning-package molint diagnostics match the clean baseline. Full
evidence and the closure checklist are in
`docs/design/evidence/27707_dn_inactive_expiry.md`.

Field acceptance before issue closure: use an immutable image containing
the complete fix, replace both CNs with active remote-lock transactions,
verify completed rollout/SQL and original-row recovery/data safety, and
keep each departed owner's error counters flat for at least 15 minutes
after membership convergence. This PR intentionally does not auto-close
the issue.

---------

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
…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
…matrixorigin#28474)

## What type of PR is this?

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

## Which issue(s) this PR fixes:

issue matrixorigin#27707

Keep the issue open until the complete fixed image passes the field
acceptance gate below; merging this PR alone is not the closure
criterion.

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

This follow-up closes two recovery gaps left after matrixorigin#28115 and matrixorigin#28343,
without weakening their transaction fences:

- **DN departed-owner recovery:** check the local raw CN inventory
before GetActiveTxn. If no endpoint exists, retain
admission/cannot-commit fences but skip futile RPCs, backend resets and
repeated missing-owner errors. Recheck membership every normal sweep,
including pending-admission CNs.
- **Safe eventual expiry:** preserve the first disconnect timestamp
rather than extending the 24-hour retention on each failure. Cleanup
validates ctl identity, recovery epoch, transaction watermark and
inactive timestamp against Resume, fresh state and replacement ctl.
In-flight Commit and persistent unknown-Commit fences keep their
independent lifetime protection.
- **CN route recovery:** a stale allocator reply can republish an
invalidated exact bind after keeper detachment. New requests then reject
before reaching the RPC refresh path, while the keeper correctly skips
the invalidated ref. Rejection now detaches only that exact cached
route, allowing subsequent discovery to fetch the converged bind. Lock,
ForwardLock and RemoteLock-on-Shared-proxy use the same helper.
- **Preserved ownership:** old transactions remain fenced; invalidated
refs remain until their consumers release them. The helper pins ref
lifetime through constant-time route detachment, preserves
newer/metadata-distinct routes and same-key valid reacquisition, and
closes outside mutation locks.

No wire/API/storage-format change, new retry layer/background worker,
pressure-policy change or configuration-default change.

Validation:

- Deterministic expiry/Resume/Commit/ctl-replacement and
missing-membership counterexamples; negative controls fail on unfixed
behavior.
- Actual Lock and forwarded/proxied handler rejection; cancellation, new
route/allocator/routing metadata, ref release/reacquisition, and close
ownership controls.
- Individual adaptive race stress, including 100 repetitions for the
route and membership recovery tests.
- Delivery integrates main `f0c31cd4b8` at `56fe252fd7`; CI checks out
the PR head, so the current dependency graph is tested explicitly. PR
head `07a73ab3e7` differs from the tested revision only in the evidence
document.
- Integrated owning package: `-short -count=1` passed (86.463s); `-short
-race -count=1` passed (91.534s). All ten exact route/membership/expiry
race tests were remeasured and repeated individually (nine at 100
repetitions, persistent-disconnect expiry at 47); all passed.
- `make build`, `make err-check`, and repository-configured
owning-package golangci passed (0 lint issues).
- Full-repository `make static-check-analysis
GOLANGCI_LINT_CONCURRENCY=2` passed (exit 0): err-check, all-package
molint and all-package golangci; golangci reported 0 issues under
unchanged repository rules/exclusions (11m21s).
- Additional repository license-header check passed (exit 0): 5,264
files checked, 0 invalid, 0 modified.
- Integrated real LogService + DN + two CN processes
(`dn-expiry-compare-vrbvaws6`, exit 0), two sequential CN replacements:
both 65-second windows completed 33 SQL commits. Departed-owner DN error
counters stayed `[6] -> [6]` and `[6,6] -> [6,6]`; the second transition
had one transient 20702, then progress. Old uncommitted values stayed
invisible, both DN fences remained, and the original locked row could be
rewritten/committed and read from the other CN. All test-owned processes
exited, with no CN fatal/panic. Binary SHA-256:
`0d65214a27aafbfd5cc0d574b71ecdbde0ba7f9539ec82bae92986b9f256f4c8`.

Limits are explicit: the real test keeps default 24-hour DN retention
and 20-second cleaner cadence but uses a 10-second CN remote-lock lease.
It is not a default-10-minute-lease test, a 24-hour soak or a field
15-minute acceptance run. The non-short `TestIssue3288` deadline also
fails at the clean investigation baseline; no assertion was weakened.
Owning-package molint diagnostics match the clean baseline. Full
evidence and the closure checklist are in
`docs/design/evidence/27707_dn_inactive_expiry.md`.

Field acceptance before issue closure: use an immutable image containing
the complete fix, replace both CNs with active remote-lock transactions,
verify completed rollout/SQL and original-row recovery/data safety, and
keep each departed owner's error counters flat for at least 15 minutes
after membership convergence. This PR intentionally does not auto-close
the issue.

---------

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
…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>

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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants