[MemCache] refactor: require an anchored lock receipt for non-root releases (#41452)

This commit is contained in:
Shuwen Wang
2026-10-10 22:43:49 +08:00
committed by GitHub
parent 44bc478863
commit 99d6f4e158
8 changed files with 302 additions and 44 deletions
@@ -218,8 +218,7 @@ class DecLockRefParams:
A segment release requires its component's boundary entry; a missing
entry must not be treated as a lock reaching the root. ``node_id`` is
``None`` only for receipts that never came from a unified-tree acquire
(legacy caches, session sentinels).
``None`` only for legacy caches; the unified tree rejects such a receipt.
"""
node_id: Optional[int] = None
@@ -696,8 +696,8 @@ class UnifiedTreeCore(UnifiedTreeCoreInterface):
@staticmethod
def _assert_receipt_anchor(node: UnifiedTreeNode, params: DecLockRefParams) -> None:
"""A receipt releases only the node its acquire returned; a mispaired
node would silently release (or steal) another holder's segment."""
assert params.node_id is None or params.node_id == node.id, (
or unanchored one would silently release (or steal) another holder's segment."""
assert params.node_id == node.id, (
f"lock receipt anchored on node {params.node_id} released on node {node.id}"
)