fix(unified radix cache w/ hicache): backup ancestor nodes before leaf in write_back eviction (#24585)

Co-authored-by: Zhangheng <hzh0425@apache.org>
This commit is contained in:
Yongji Wu
2026-05-17 15:58:46 +08:00
committed by GitHub
co-authored by Zhangheng
parent 46e0f5007d
commit e547f3f804
2 changed files with 54 additions and 3 deletions
@@ -390,6 +390,12 @@ class UnifiedRadixCache(BasePrefixCache):
for component in self._components_tuple:
component.drive_eviction(params=params, tracker=tracker)
if (
self.cache_controller is not None
and self.cache_controller.write_policy == "write_back"
):
self.writing_check(write_back=True)
self.update_eviction_metrics(sum(tracker.values()), start_time)
return EvictResult(
num_tokens_evicted=tracker[BASE_COMPONENT_TYPE],
@@ -1653,6 +1659,11 @@ class UnifiedRadixCache(BasePrefixCache):
if self.session.any_holding_kv():
return
write_back = (
self.cache_controller is not None
and self.cache_controller.write_policy == "write_back"
)
errors: list[str] = []
E = errors.append
all_nodes = self._collect_all_nodes()
@@ -1709,7 +1720,7 @@ class UnifiedRadixCache(BasePrefixCache):
p_hst = node.parent.component_data[FCT].host_value is not None
if full_dev and not p_dev:
E(f"node {nid} device present but parent {node.parent.id} evicted")
if full_hst and not p_hst:
if full_hst and not p_hst and not write_back:
E(f"node {nid} backed up but parent {node.parent.id} not backed up")
# Lock hierarchy and counters must stay sane.