Skip to content

[Bug]: fixedSlice refcount resurrection can return a live slice to the pool and crash CN #27884

Closed

Description

@VioletQwQ-0

Is there an existing issue for the same bug?

  • I searched open issues and pull requests for fixedSlice, lockservice refcount, invalid refcount, and the observed index-out-of-range panic.

Branch Name

main

Commit ID

b870113dab4d340b42ea0b489aae3430b49be6e1

Other Environment Information

  • OS: macOS arm64
  • Go: 1.26.4
  • Package: pkg/lockservice

Actual Behavior

cowSlice.slice loads the current fixedSlice pointer and then increments its reference count unconditionally. A concurrent COW replacement can retire that object and reduce its reference count to zero between those two operations. The reader then revives the retired object from zero, fails the generation check, and returns the same object to sync.Pool a second time.

Measured on the exact commit above, a deterministic production-path interleaving makes one retired fixedSlice execute two effective pool releases. This can give two live owners the same pooled object. In the multi-CN QA for #27806, CN2 subsequently observed a capacity-1 slice with stale length 1 and panicked in fixedSlice.append; that incident is supporting evidence, while the deterministic double-release oracle is the current-main proof.

Expected Behavior

Once a fixedSlice reference count reaches zero, stale readers must not resurrect it. Each generation must have exactly one effective return to the pool, and a pooled object must have only one live acquisition owner.

Steps to Reproduce

  1. Create a capacity-1 cowSlice.
  2. Enter cowSlice.slice after it captures the current version and pointer but before it acquires a reference.
  3. Force a real cowSlice.append COW replacement from that barrier.
  4. Let the replacement publish the new pointer, advance the version, and unref the old object to zero.
  5. Resume the reader.
  6. On current main, the unconditional ref() revives the old object; the failed version CAS then unref()s it and releases it a second time.

Focused oracle: TestCowSliceSliceReadConcurrentWithAppend

  • Base result: FAIL, expected one release but observed two.
  • Test-only barrier patch SHA-256: a353103622f372112aa40f195d8c4a69715c135e65ac98b2a7bc65c03f79c4d0.
  • The test uses the real slice -> append -> replace -> unref -> pool release path and no sleeps.

Additional information

Activity

  1. added
    kind/bug
    on Aug 31, 2026
  2. added
    severity/s0
    and removed on Aug 31, 2026
  3. VioletQwQ-0 commented on Sep 2, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    补充 #27884 修复后的独立多 CN 产品烟测证据。

    版本与环境

    • 修复 PR:fix(lockservice): prevent fixedSlice refcount resurrection #27928,已合并;merge commit:c7fb30d91ed46e6b9d0a0a6cde4af2f690bef37f
    • 测试精确头:44b0803bdc64e1169fa60a603786bee3a5972abc,已确认包含上述 merge commit
    • 平台:Linux/arm64
    • 精确镜像:pr27806:44b0803-arm64
    • Image ID:sha256:68290448b5db2bbad5484e6cdb892bcb7395451f7cb3145f7cffe85cf4c9f586
    • 二进制 SHA256:65ca8b42839dacf812a584de72a633a5d8f2a29902729c8321b324ff4915cea1
    • 拓扑:CN1/CN2 直连,未使用 Proxy;后续包含 CN2 重启与 CN3 新加入
    • 协议:所有服务 CN 使用 MORPC v43

    场景与终态

    该运行是 #27806 的精确头直连矩阵,同时覆盖了此前发现 #27884 时被 fixedSlice.append panic 阻断的多 CN 产品路径:

    • CN1/CN2 独立身份绑定与双端预热
    • rollback
    • INSERT、UPDATE、DELETE
    • 首次目标 fence RPC 丢失与重试
    • durable commit 后 sender CN2 中断,CN1 pull recovery
    • CN2 重启及 CN3 加入

    结构化终态:

    • MATRIX_PASS
    • teardown:PASS
    • fatal scan:空
    • 未观察到 CN panic、hang 或异常退出

    generation 从 setup 0:1 经 INSERT 0:2、UPDATE 0:4、DELETE 0:5、lost RPC 0:6 收敛至 sender interruption 0:7。

    QA 结论与边界

    这份证据满足 #27928 PR 描述中尚缺的“修复后 Linux/arm64 独立多 CN smoke”技术门禁。它与 #27928 已有的确定性 unit/race 证据共同覆盖:

    • unit/race:禁止 refcount 从 0 复活、每代只释放一次以及 close 顺序不变量
    • 多 CN smoke:真实部署路径不再出现原先的 fixedSlice.append panic、hang 或异常退出

    本评论是自动化/产品烟测证据关联,不代替测试人员或 issue owner 的正式 QA 接受。关闭 #27884 前仍需明确的 tester/owner PASS,包含测试版本、环境和终态结果;GitHub CI 结论也是独立门禁。

  4. VioletQwQ-0 commented on Sep 3, 2026

    @VioletQwQ-0
    CollaboratorAuthor

    @Ariznawlll 该问题现转入测试验收,请复核并正式接受现有 smoke 证据,不需要重新执行完整多 CN 矩阵。

    修复版本

    • 修复 PR:fix(lockservice): prevent fixedSlice refcount resurrection #27928,状态 MERGED
    • PR source head:e5d3ff5937cc1caed7ad937701eeab4827bda388
    • merge commit:c7fb30d91ed46e6b9d0a0a6cde4af2f690bef37f
    • 本次转测时 main:1092ab739c120052fff0b8d1ff27854663cd098f
    • 已有产品 smoke 精确头:44b0803bdc64e1169fa60a603786bee3a5972abc,已确认包含上述 merge commit

    已有验证证据

    • 平台:Linux/arm64
    • 镜像:pr27806:44b0803-arm64
    • Image ID:sha256:68290448b5db2bbad5484e6cdb892bcb7395451f7cb3145f7cffe85cf4c9f586
    • 二进制 SHA256:65ca8b42839dacf812a584de72a633a5d8f2a29902729c8321b324ff4915cea1
    • 拓扑:CN1/CN2 直连,包含 CN2 重启与 CN3 新加入;未使用 Proxy;所有服务 CN 使用 MORPC v43
    • 场景:双端预热、rollback、INSERT/UPDATE/DELETE、首次目标 fence RPC 丢失与重试、durable commit 后 sender CN2 中断及 CN1 pull recovery、CN2 重启和 CN3 加入
    • 终态:MATRIX_PASS,teardown PASS,fatal scan 为空,未观察到 CN panic、hang 或异常退出
    • 单元/并发回归:禁止 refcount 从 0 复活、每代唯一释放、close/log 顺序及生产 close 终态断言均已覆盖;PR 已获批准且无未解决 review thread
    • 原始 smoke 证据:[Bug]: fixedSlice refcount resurrection can return a live slice to the pool and crash CN #27884 的上一条评论

    本次验收范围

    请仅检查上述精确版本、环境、覆盖场景和结构化终态是否足以接受 #27884 的修复,不要求重新跑完整矩阵。PR 页面现存的 SCA runner 失联和 TKE BVT 75 分钟超时,按 issue owner 本次决定不作为转测/验收阻塞,也不要求重跑。

    如证据可接受,请回复明确的 PASS,并带上接受的版本、环境及终态;如不可接受,请回复 FAIL 并指出具体证据缺口或不符合项。在收到明确 PASS 前,该 issue 保持 OPEN 和 phase/testing。

  5. Ariznawlll commented on Sep 5, 2026

    @Ariznawlll
    Collaborator

    测试验收结论

    覆盖场景

    • CN1/CN2 独立身份绑定与双端预热
    • rollback、INSERT、UPDATE、DELETE
    • 首次目标 fence RPC 丢失与重试
    • durable commit 后 sender CN2 中断及 CN1 pull recovery
    • CN2 重启与 CN3 加入

    结果

    • MATRIX_PASS
    • teardown:PASS
    • fatal scan:空
    • 未观察到 fixedSlice.append panic、CN panic、hang 或异常退出
    • 相关 unit/race 证据已覆盖 refcount 复活、重复释放和 close 顺序不变量

    结论

    修复后的真实多 CN 产品路径验证通过,满足本 issue 的验收条件,现关闭 issue。

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

Metadata

Metadata

Assignees

Labels

kind/bugphase/testingseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions