Skip to content

KVCacheManager does not roll back partial allocation when alloc_page fails #364

Description

@shipiyouniao

Summary

KVCacheManager.alloc() can partially consume reserved blocks or blocks from existing pages before it needs to request another physical page. If PageAllocator.alloc_page() then raises RuntimeError because the shared physical pool is exhausted, the partial allocation is not rolled back.

Problem

This is a race/failure-mode issue under multi-instance pressure. available_size() can report enough logical capacity, but another instance may consume physical pages before the current instance reaches alloc_page(). In that case, the current allocation attempt can fail after it has already removed block ids from reserved blocks or page free lists.

Expected behavior

If a physical page allocation fails after partial block allocation, KVCacheManager.alloc() should roll back the partial block ids and return None as an allocation miss. The scheduler or caller can then apply its existing allocation-miss handling instead of leaking blocks or crashing.

Impact

This complements the existing EngineCore allocation-miss handling. It protects the lower-level allocator path where the failure originates, especially when multiple kvcached instances share the same physical KV pool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions