Skip to content

[4.2-dev] fix(lockservice): prevent fixedSlice refcount resurrection - #33206

Merged
XuPeng-SH merged 2 commits into
matrixorigin:4.2-devfrom
VioletQwQ-0:codex/4.2-dev-lock-slice-lifetime
Nov 25, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:4.2-devfrom
VioletQwQ-0:codex/4.2-dev-lock-slice-lifetime

Conversation

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG
  • 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.

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

@mergify

mergify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH

XuPeng-SH commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: a15820bab01714bad98a65785a7497270066b4d5

Review completed. Read the assessment.

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

mo-bot review · mo-bot-local · review

Commit: a15820bab01714bad98a65785a7497270066b4d5

Assessment: approve

The positive-only reference acquisition prevents retired slices from being resurrected, and the existing version check handles stale readers across replacement and reuse. Moving the completion log before detach preserves the slice owner through that read. No actionable defects remain.

Model: gpt-6.1-terra / max

Session: 01a210f5-236b-7a40-a956-fdee040ef313 · slot 3 · generation 2

Validation:

  • Preflight and git diff --check passed; receipts checks/1795591410879581998-2.json and checks/1795591410818751758-2.json.

  • The focused lockservice race run passed 23 selected tests, including the reported interleaving and retryable-close controls; log focused-race-retry.log and receipt checks/1795591922041313315-2.json.

  • Eight individual concurrency and close tests each passed 100 race-detector repetitions; logs race-Test*.log and corresponding receipts are retained.

  • The full lockservice package passed under the race detector with 496 top-level tests, no skips, and no race reports; log package-race.log and receipt checks/1795592176103956645-2.json.

  • The linked main-branch fix has identical slice.go, slice_test.go, and reuse.go; its accepted multi-CN smoke is relevant context for the core fix.

Limitations:

  • No separate 4.2 multi-CN lock-churn or restart smoke was run. The PR identifies that as pending release validation; the linked issue's accepted smoke used the main-branch fix.

  • An initial test attempt was interrupted during slow dependency downloads. The subsequent focused and package runs completed using the assigned cache and the official Go module proxy.

@mergify mergify Bot added the queued label Nov 25, 2026
@mergify

mergify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue · pull request dequeued

25 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Wed 25 Nov, 07:38 · rule release-4.2 · triggered by rule Automatic queue on approval for release-4.2
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 08:03 · 8636bc2

Reason

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

To get back in the queue

  • Push a change if one is needed: the pull request is queued again once its queue conditions match.
  • If no change is needed, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

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

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

@Ariznawlll 请协助验收这次锁服务修复在 4.2-dev 的回补。合并提交为 ef9dac896bcbf26a27af583e853a2a17694c84d4。原问题 #27884 已完成主分支验收,本次请在这条 PR 下记录 4.2 的结果。

原故障发生在并发读写锁记录时:读者可能重新引用已经回收的对象,导致重复回收,计算节点随后可能崩溃。该回补已有针对引用计数和事务释放顺序的定向单测记录,最终 PR 的必需检查未通过,多节点发布场景仍待验证。

请在包含上述提交的 4.2 构建上,让至少两个计算节点的事务并发更新同一组记录,通过提交和回滚反复获取、释放锁。在负载持续期间逐个重启计算节点。请确认重启后新事务能再次获得同一组记录的锁并完成提交或回滚,已提交的数据可读、已回滚的更新不可见,且没有非预期的进程退出或持续卡死。

请在此回复通过或失败,并附实际测试提交、部署拓扑、重启顺序和事务终态。如果失败,请注明首次异常的节点、步骤及对应日志或运行链接。

@VioletQwQ-0
VioletQwQ-0 deleted the codex/4.2-dev-lock-slice-lifetime branch December 1, 2026 03:47

This branch was successfully deployed

No deployments
ci — 8636bc25 Deployed Nov 25, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working kind/test-ci 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