[HiCache] Fix write-back SWA insert backups tripping the write-through pending-ack assert (#42264)

Co-authored-by: merrymercy <merrymercy@users.noreply.github.com>
Co-authored-by: 842974287 <842974287@users.noreply.github.com>
(cherry picked from commit 2bae12b9b3)
This commit is contained in:
metamergebot
2026-10-08 15:37:43 +08:00
committed by minke.yu
parent 4ef799aaa6
commit 60e80ac7d1
4 changed files with 176 additions and 9 deletions
@@ -1360,7 +1360,8 @@ class UnifiedTreeCore(UnifiedTreeCoreInterface):
)
def _insert_tail_step(self, state: _InsertWalkState) -> None:
"""Refresh the LRUs and append terminal backup actions."""
"""Refresh the LRUs and append the insert backup: a new-leaf write-through,
or an SWA window publish on an existing backed node."""
if state.target_node is not self.root_node:
for component in self.components:
if component.component_type == BASE_COMPONENT_TYPE:
@@ -1371,7 +1372,9 @@ class UnifiedTreeCore(UnifiedTreeCoreInterface):
if self._should_backup_after_insert(state):
state.pending_actions.append(
self._build_backup_kv_action(state.target_node)
self._build_backup_kv_action(
state.target_node, write_back=self.is_write_back
)
)
def _split_node(
@@ -2350,7 +2353,8 @@ class UnifiedTreeCore(UnifiedTreeCoreInterface):
def _build_backup_kv_action(
self, node: UnifiedTreeNode, write_back: bool = False
) -> BackupKV:
"""Build the backup action for a node and its not-yet-persisted ancestors."""
"""Build the backup action for a node; write-through also chains its
unbacked ancestors."""
chain = [node]
if not write_back:
ancestor = node.parent