Skip to content

fix(lockservice): prevent fixedSlice refcount resurrection - #27928

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/lockservice-fixed-slice-ref
Sep 1, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/lockservice-fixed-slice-ref

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #27884

What this PR does / why we need it:

cowSlice.slice could increment a fixedSlice reference count after a concurrent COW replacement had retired the object and reduced its count to zero. The reader could therefore resurrect a pooled generation and, after the version check failed, return the same generation to the pool a second time. That duplicate pool ownership can alias live owners and corrupt the slice seen by fixedSlice.append, causing a CN panic.

Changes:

  • Add tryRef, which acquires a transient reader reference only from a positive count with a CAS loop.
  • Make initRef the only 0 -> 1 pool-generation claim and reject non-retired objects.
  • Retry cowSlice.slice when the observed generation is already retired, and symmetrically unref a reference when version validation loses its CAS race.
  • Keep the unique 1 -> 0 transition as the only cleanup and pool return path.
  • Read the transaction completion log through slice() before a successful close path detaches and releases its cowSlice owner; this prevents a post-close debug logger from spinning on a zero-reference slice.

Non-goals:

  • No public API, RPC, configuration, catalog, wire schema, or persisted-format change.
  • No FULLTEXT2 cache-coherence behavior from fix(fulltext2): fence cross-CN cache generations #27806 is implemented here; this is the independent lockservice crash blocker found while exercising that distributed path.

Validation:

  • Exact PR base: b23beeea896f574a57628b44fb769cda3775cb84; current source patch SHA-256: ddd7beb2aa819ee716a1ba0a70a8169c91c88fe81dcca6b1d56d886eff138ed5.
  • Base behavior: on exact base b23beeea896f574a57628b44fb769cda3775cb84, a read-only oracle overlay that moves fs.ref() after the existing slice hook deterministically reproduces duplicate release counts (expected 1/2, observed 2/3) in TestCowSliceSliceReadConcurrentWithAppend.
  • Candidate behavior: 16 focused lifecycle tests (15 fixedSlice/cowSlice tests plus TestCloseWithoutFreeWithContextLogsBeforeSliceRelease) passed; every focused test passed independently with -race -count=100; complete pkg/lockservice normal and race suites passed. The close-order regression uses the production transaction close path and a one-second bounded-return guard, and now asserts txn.lockHolders is empty plus fsp.releaseV == 1.
  • Test-authenticity attack: a read-only overlay deleting the successful removeClosedLockTable call fails at the holder-empty assertion; the prior log-only test passed that same no-detach mutation.
  • Build gates: go list ./pkg/lockservice, go build ./pkg/lockservice, go vet ./pkg/lockservice, git diff --check, and the repository CGo-contract cmd/mo-service host build passed. The local build was Darwin/arm64 with binary SHA-256 12747dc2bc0f26e11dfbc0cd2c79b7a6d02a93b166ab9438f3482b418aa722cb.
  • Benchmark: BenchmarkCowSliceRead used 15 samples per side on the same Darwin/arm64 host and implementation; base median 16.80 ns/op, candidate median 16.93 ns/op (+0.77%, within the 10% gate); both sides reported 0 B/op and 0 allocs/op.
  • Semantic preflight: clean schema-v6 manifest at head 9ac0d9fbf01192bca0ba6ecacebe7cf0aab7e8e6, diff hash 8df3051771ab199391d8e3782a3e7da550bf723bd8eab84b2f8f3192b31aab4d, validator exact output PASS semantic=PASS.
  • Manual two-CN: the earlier Linux/arm64 binary and two-CN run predates the close-order fix and is intentionally superseded. No current two-CN PASS is claimed for this head; a fresh user-run Linux/arm64 smoke is required before QA acceptance.
  • BVT: N/A — the zero-reference linearization and close/log ordering are internal lockservice interleavings that SQL/BVT cannot deterministically control. Equivalent regression coverage uses the production-path barrier tests, close-order regression, and race stress listed above.
  • QA required: Yes — this shared-state lifecycle defect can crash or hang a CN, and formal Linux/arm64 multi-CN verification remains outstanding.

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

The zero-ref non-resurrection design fixes the interleaving in #27884, but the stricter lifetime rule exposes a deterministic use-after-close in the existing cleanup path.

closeWithContextInternal calls removeClosedLockTable(...) on a successful detach (or a non-local direct unlock), which synchronously executes cs.close() and resets the current fixedSlice to ref=0. It then calls logTxnUnlockTableCompleted(..., cs); with debug logging enabled that function calls cs.slice().

With this patch, if the pooled cowSlice has not yet been reused, tryRef() keeps returning false and slice() spins forever, so Unlock/cleanup (and a parallel cleanup's WaitGroup) never completes. If the cowSlice is reused before the log call, the log can instead read an unrelated transaction generation. The new tests cover an already-acquired reader surviving close, but not a read started after close, which is the production ordering here.

Please log/capture the retained slice before removeClosedLockTable frees the cowSlice (or otherwise enforce a generation-safe closed-state contract), and add a deterministic regression test for the successful-detach + debug-log ordering.

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed in commit a92d1625ce891310ab23790eb04b3f29535aa351.

The completion log now reads the cowSlice through slice() before the successful detach calls removeClosedLockTable and releases the owner. Added TestCloseWithoutFreeWithContextLogsBeforeSliceRelease, which exercises the production close path with a debug MOLogger and a bounded-return guard; it passes in normal and -race -count=100 runs. The focused lifecycle set is now 16 tests, and the full pkg/lockservice normal/race suites pass.

The exact-base read-only overlay reproduces the original zero-ref duplicate-release counterexample, while the current candidate passes the close-order regression. Please re-review this head; a fresh Linux/arm64 two-CN smoke remains required for QA.

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

Deep-reviewed exact head 9ac0d9f against exact base b23beee from the refcount, generation/ABA, pool ownership, close ordering, retry, starvation, map-mutation, logging, performance, and unhappy-path angles.

The design establishes the required invariant: zero is terminal for one fixedSlice generation, only pool acquisition may claim 0 to 1, and a reader may increment only a positive generation. A stale reader racing replacement cannot resurrect a retired generation; if the address has already been reused, its balanced transient ref applies to the new positive generation and the cowSlice version check prevents returning it as old data. The unique 1 to 0 transition remains the only cleanup/pool-return owner.

The latest close-order fix closes my earlier blocker: completion logging acquires and releases its reader reference before successful detach releases the cowSlice owner. Retryable detach remains sequential, while the parallel release path does not concurrently mutate holder maps. I found no remaining leak, double-release, use-after-close, wait cycle, busy-spin production path, or material hot-path regression. This is a focused internal bug fix and does not require the feature design gate.

Exact-head diff check passed. Focused fixedSlice/cowSlice and production close regressions passed under race detection for 50 iterations, and the complete pkg/lockservice suite passed locally in 99.753s. Latest substantive CI is terminal green. Formal Linux/arm64 multi-CN QA remains appropriate for this crash-class change but is not a code-review blocker.

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

mergify Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-01 07:46 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-01 07:48 UTC · at e5d3ff5937cc1caed7ad937701eeab4827bda388

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

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27928 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.

Failing checks:

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 c7fb30d into matrixorigin:main Sep 1, 2026
18 of 20 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 1, 2026
VioletQwQ-0 added a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
…gin#27928)

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

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

`cowSlice.slice` could increment a `fixedSlice` reference count after a
concurrent COW replacement had retired the object and reduced its count
to zero. The reader could therefore resurrect a pooled generation and,
after the version check failed, return the same generation to the pool a
second time. That duplicate pool ownership can alias live owners and
corrupt the slice seen by `fixedSlice.append`, causing a CN panic.

Changes:

- Add `tryRef`, which acquires a transient reader reference only from a
positive count with a CAS loop.
- Make `initRef` the only `0 -> 1` pool-generation claim and reject
non-retired objects.
- Retry `cowSlice.slice` when the observed generation is already
retired, and symmetrically `unref` a reference when version validation
loses its CAS race.
- Keep the unique `1 -> 0` transition as the only cleanup and pool
return path.
- Read the transaction completion log through `slice()` before a
successful close path detaches and releases its `cowSlice` owner; this
prevents a post-close debug logger from spinning on a zero-reference
slice.

Non-goals:

- No public API, RPC, configuration, catalog, wire schema, or
persisted-format change.
- No FULLTEXT2 cache-coherence behavior from matrixorigin#27806 is implemented here;
this is the independent lockservice crash blocker found while exercising
that distributed path.

Validation:

- Exact PR base: `b23beeea896f574a57628b44fb769cda3775cb84`; current
source patch SHA-256:
`ddd7beb2aa819ee716a1ba0a70a8169c91c88fe81dcca6b1d56d886eff138ed5`.
- Base behavior: on exact base
`b23beeea896f574a57628b44fb769cda3775cb84`, a read-only oracle overlay
that moves `fs.ref()` after the existing slice hook deterministically
reproduces duplicate release counts (`expected 1/2`, observed `2/3`) in
`TestCowSliceSliceReadConcurrentWithAppend`.
- Candidate behavior: 16 focused lifecycle tests (15 fixedSlice/cowSlice
tests plus `TestCloseWithoutFreeWithContextLogsBeforeSliceRelease`)
passed; every focused test passed independently with `-race -count=100`;
complete `pkg/lockservice` normal and race suites passed. The
close-order regression uses the production transaction close path and a
one-second bounded-return guard, and now asserts `txn.lockHolders` is
empty plus `fsp.releaseV == 1`.
- Test-authenticity attack: a read-only overlay deleting the successful
`removeClosedLockTable` call fails at the holder-empty assertion; the
prior log-only test passed that same no-detach mutation.
- Build gates: `go list ./pkg/lockservice`, `go build
./pkg/lockservice`, `go vet ./pkg/lockservice`, `git diff --check`, and
the repository CGo-contract `cmd/mo-service` host build passed. The
local build was Darwin/arm64 with binary SHA-256
`12747dc2bc0f26e11dfbc0cd2c79b7a6d02a93b166ab9438f3482b418aa722cb`.
- Benchmark: `BenchmarkCowSliceRead` used 15 samples per side on the
same Darwin/arm64 host and implementation; base median `16.80 ns/op`,
candidate median `16.93 ns/op` (`+0.77%`, within the 10% gate); both
sides reported `0 B/op` and `0 allocs/op`.
- Semantic preflight: clean schema-v6 manifest at head
`9ac0d9fbf01192bca0ba6ecacebe7cf0aab7e8e6`, diff hash
`8df3051771ab199391d8e3782a3e7da550bf723bd8eab84b2f8f3192b31aab4d`,
validator exact output `PASS semantic=PASS`.
- Manual two-CN: the earlier Linux/arm64 binary and two-CN run predates
the close-order fix and is intentionally superseded. No current two-CN
PASS is claimed for this head; a fresh user-run Linux/arm64 smoke is
required before QA acceptance.
- BVT: N/A — the zero-reference linearization and close/log ordering are
internal lockservice interleavings that SQL/BVT cannot deterministically
control. Equivalent regression coverage uses the production-path barrier
tests, close-order regression, and race stress listed above.
- QA required: Yes — this shared-state lifecycle defect can crash or
hang a CN, and formal Linux/arm64 multi-CN verification remains
outstanding.

---------

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

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

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

`cowSlice.slice` could increment a `fixedSlice` reference count after a
concurrent COW replacement had retired the object and reduced its count
to zero. The reader could therefore resurrect a pooled generation and,
after the version check failed, return the same generation to the pool a
second time. That duplicate pool ownership can alias live owners and
corrupt the slice seen by `fixedSlice.append`, causing a CN panic.

Changes:

- Add `tryRef`, which acquires a transient reader reference only from a
positive count with a CAS loop.
- Make `initRef` the only `0 -> 1` pool-generation claim and reject
non-retired objects.
- Retry `cowSlice.slice` when the observed generation is already
retired, and symmetrically `unref` a reference when version validation
loses its CAS race.
- Keep the unique `1 -> 0` transition as the only cleanup and pool
return path.
- Read the transaction completion log through `slice()` before a
successful close path detaches and releases its `cowSlice` owner; this
prevents a post-close debug logger from spinning on a zero-reference
slice.

Non-goals:

- No public API, RPC, configuration, catalog, wire schema, or
persisted-format change.
- No FULLTEXT2 cache-coherence behavior from matrixorigin#27806 is implemented here;
this is the independent lockservice crash blocker found while exercising
that distributed path.

Validation:

- Exact PR base: `b23beeea896f574a57628b44fb769cda3775cb84`; current
source patch SHA-256:
`ddd7beb2aa819ee716a1ba0a70a8169c91c88fe81dcca6b1d56d886eff138ed5`.
- Base behavior: on exact base
`b23beeea896f574a57628b44fb769cda3775cb84`, a read-only oracle overlay
that moves `fs.ref()` after the existing slice hook deterministically
reproduces duplicate release counts (`expected 1/2`, observed `2/3`) in
`TestCowSliceSliceReadConcurrentWithAppend`.
- Candidate behavior: 16 focused lifecycle tests (15 fixedSlice/cowSlice
tests plus `TestCloseWithoutFreeWithContextLogsBeforeSliceRelease`)
passed; every focused test passed independently with `-race -count=100`;
complete `pkg/lockservice` normal and race suites passed. The
close-order regression uses the production transaction close path and a
one-second bounded-return guard, and now asserts `txn.lockHolders` is
empty plus `fsp.releaseV == 1`.
- Test-authenticity attack: a read-only overlay deleting the successful
`removeClosedLockTable` call fails at the holder-empty assertion; the
prior log-only test passed that same no-detach mutation.
- Build gates: `go list ./pkg/lockservice`, `go build
./pkg/lockservice`, `go vet ./pkg/lockservice`, `git diff --check`, and
the repository CGo-contract `cmd/mo-service` host build passed. The
local build was Darwin/arm64 with binary SHA-256
`12747dc2bc0f26e11dfbc0cd2c79b7a6d02a93b166ab9438f3482b418aa722cb`.
- Benchmark: `BenchmarkCowSliceRead` used 15 samples per side on the
same Darwin/arm64 host and implementation; base median `16.80 ns/op`,
candidate median `16.93 ns/op` (`+0.77%`, within the 10% gate); both
sides reported `0 B/op` and `0 allocs/op`.
- Semantic preflight: clean schema-v6 manifest at head
`9ac0d9fbf01192bca0ba6ecacebe7cf0aab7e8e6`, diff hash
`8df3051771ab199391d8e3782a3e7da550bf723bd8eab84b2f8f3192b31aab4d`,
validator exact output `PASS semantic=PASS`.
- Manual two-CN: the earlier Linux/arm64 binary and two-CN run predates
the close-order fix and is intentionally superseded. No current two-CN
PASS is claimed for this head; a fresh user-run Linux/arm64 smoke is
required before QA acceptance.
- BVT: N/A — the zero-reference linearization and close/log ordering are
internal lockservice interleavings that SQL/BVT cannot deterministically
control. Equivalent regression coverage uses the production-path barrier
tests, close-order regression, and race stress listed above.
- QA required: Yes — this shared-state lifecycle defect can crash or
hang a CN, and formal Linux/arm64 multi-CN verification remains
outstanding.

---------

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

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

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

`cowSlice.slice` could increment a `fixedSlice` reference count after a
concurrent COW replacement had retired the object and reduced its count
to zero. The reader could therefore resurrect a pooled generation and,
after the version check failed, return the same generation to the pool a
second time. That duplicate pool ownership can alias live owners and
corrupt the slice seen by `fixedSlice.append`, causing a CN panic.

Changes:

- Add `tryRef`, which acquires a transient reader reference only from a
positive count with a CAS loop.
- Make `initRef` the only `0 -> 1` pool-generation claim and reject
non-retired objects.
- Retry `cowSlice.slice` when the observed generation is already
retired, and symmetrically `unref` a reference when version validation
loses its CAS race.
- Keep the unique `1 -> 0` transition as the only cleanup and pool
return path.
- Read the transaction completion log through `slice()` before a
successful close path detaches and releases its `cowSlice` owner; this
prevents a post-close debug logger from spinning on a zero-reference
slice.

Non-goals:

- No public API, RPC, configuration, catalog, wire schema, or
persisted-format change.
- No FULLTEXT2 cache-coherence behavior from matrixorigin#27806 is implemented here;
this is the independent lockservice crash blocker found while exercising
that distributed path.

Validation:

- Exact PR base: `b23beeea896f574a57628b44fb769cda3775cb84`; current
source patch SHA-256:
`ddd7beb2aa819ee716a1ba0a70a8169c91c88fe81dcca6b1d56d886eff138ed5`.
- Base behavior: on exact base
`b23beeea896f574a57628b44fb769cda3775cb84`, a read-only oracle overlay
that moves `fs.ref()` after the existing slice hook deterministically
reproduces duplicate release counts (`expected 1/2`, observed `2/3`) in
`TestCowSliceSliceReadConcurrentWithAppend`.
- Candidate behavior: 16 focused lifecycle tests (15 fixedSlice/cowSlice
tests plus `TestCloseWithoutFreeWithContextLogsBeforeSliceRelease`)
passed; every focused test passed independently with `-race -count=100`;
complete `pkg/lockservice` normal and race suites passed. The
close-order regression uses the production transaction close path and a
one-second bounded-return guard, and now asserts `txn.lockHolders` is
empty plus `fsp.releaseV == 1`.
- Test-authenticity attack: a read-only overlay deleting the successful
`removeClosedLockTable` call fails at the holder-empty assertion; the
prior log-only test passed that same no-detach mutation.
- Build gates: `go list ./pkg/lockservice`, `go build
./pkg/lockservice`, `go vet ./pkg/lockservice`, `git diff --check`, and
the repository CGo-contract `cmd/mo-service` host build passed. The
local build was Darwin/arm64 with binary SHA-256
`12747dc2bc0f26e11dfbc0cd2c79b7a6d02a93b166ab9438f3482b418aa722cb`.
- Benchmark: `BenchmarkCowSliceRead` used 15 samples per side on the
same Darwin/arm64 host and implementation; base median `16.80 ns/op`,
candidate median `16.93 ns/op` (`+0.77%`, within the 10% gate); both
sides reported `0 B/op` and `0 allocs/op`.
- Semantic preflight: clean schema-v6 manifest at head
`9ac0d9fbf01192bca0ba6ecacebe7cf0aab7e8e6`, diff hash
`8df3051771ab199391d8e3782a3e7da550bf723bd8eab84b2f8f3192b31aab4d`,
validator exact output `PASS semantic=PASS`.
- Manual two-CN: the earlier Linux/arm64 binary and two-CN run predates
the close-order fix and is intentionally superseded. No current two-CN
PASS is claimed for this head; a fresh user-run Linux/arm64 smoke is
required before QA acceptance.
- BVT: N/A — the zero-reference linearization and close/log ordering are
internal lockservice interleavings that SQL/BVT cannot deterministically
control. Equivalent regression coverage uses the production-path barrier
tests, close-order regression, and race stress listed above.
- QA required: Yes — this shared-state lifecycle defect can crash or
hang a CN, and formal Linux/arm64 multi-CN verification remains
outstanding.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
XuPeng-SH pushed a commit that referenced this pull request Nov 25, 2026
…33206)

## What type of PR is this?

- [x] BUG
- [x] Test and CI

## Which issue(s) this PR fixes:

Related to #27884. Backports #27928 to `4.2-dev`.

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

A reader must not take a reference to a retired fixedSlice while its
copy-on-write owner publishes a replacement. Initialize references at
pool checkout, acquire reader references only while the count is
positive, and complete transaction unlock logging before detaching the
lock slice on the 4.2 close path.

Base `bb197e5118507d830f5e50f99a2676bb88a8d62f`, head
`a15820bab01714bad98a65785a7497270066b4d5`. Focused lockservice tests
passed on Go 1.26.4/darwin-arm64, including deterministic
reader/publication interleavings, pool ownership and debug logging
during transaction detach. `git diff --check` passed.

BVT: N/A for the deterministic regression. SQL cannot suspend the
copy-on-write reader between pointer load and reference acquisition or
inspect the pool's reference ownership. The lockservice tests drive
those transitions and verify the final state directly.

QA required: yes. Cross-CN lock churn and rolling restart still need
release validation.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@VioletQwQ-0
VioletQwQ-0 deleted the codex/lockservice-fixed-slice-ref branch December 1, 2026 03:47

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.

3 participants