#5391·LMCache

aborted async lookups that never receive a worker response leak pinned memory objects and scheduler-side state

Author: ptimizeroracleCreated Sep 28, 2026Updated Sep 28, 2026

Label

bug (cannot set labels myself)

Describe the bug

pinned memory objects and scheduler-side state leak whenever an async lookup takes pins but never delivers a response to the scheduler. found by code reading on main @ 631a59b, not a runtime repro, full chain below.

the lookup flow takes pins before completion:

  • storage_manager.py:733 batched_async_contains(lookup_id, keys, pin) pins every matching key (documented at storage_manager.py:743-746)
  • the coroutine is fire-and-forget: cache_engine.py:1391-1401 schedules it with asyncio.run_coroutine_threadsafe and never observes the returned future, so exceptions inside the coroutine are unobserved
  • responses are only sent on success (storage_manager.py:653) and on the zero-hit early return (storage_manager.py:791-793); there is no failure-path response
  • prefetch_single_done_callback is pass (storage_manager.py:544-557), so an individual loading-task failure is also unhandled
  • prefetch_all_done_callback sets the LOADING event to DONE before calling task.result() (storage_manager.py:574-577), so when a loading task raises, the event is DONE but send_response_to_scheduler at :653 is never reached

on the scheduler side the abort machinery is response-gated:

  • lookup_cache times out after lookup_timeout_ms (default 3000, config.py:457-461), logs one warning, returns 0 so vllm recomputes (lmcache_async_lookup_client.py:176-186)
  • cancel_lookup only adds the id to aborted_lookups (lmcache_async_lookup_client.py:257-259)
  • _cleanup_finished_aborted_lookups only drains aborted lookups whose reqs_status entry is not None, i.e. only after a response arrived (lmcache_async_lookup_client.py:265-283). a lookup that never received a response never becomes "finished", so the LookupCleanupMsg that would trigger cleanup_memory_objs is never sent
  • even if a cleanup message were sent, cleanup_memory_objs early-returns unless the LOADING event is DONE (cache_engine.py:1412-1419)

pinned means unevictable: can_evict returns not self.is_pinned (memory_management.py:1030-1037).

three failure lanes reach the same terminal state:

  1. an awaited step raises mid-coroutine (e.g. a remote backend raises on tier 2 after tier 1 already pinned): coroutine dies before the gather, event never DONE, no response. pins from tier 1 leak
  2. a loading task raises: event is set DONE at storage_manager.py:574 but the response send at :653 is skipped when task.result() re-raises inside the done callback. pins leak even though cleanup would have worked
  3. the response is delivered but lost client-side (decode failure at lmcache_async_lookup_client.py:248-249): worker holds pins and a DONE event forever, scheduler never marks the lookup finished

lane 3 also means worker-side lookup hit metrics can diverge from what the scheduler actually received.

the designed self-heal path works only when a response eventually arrives: late response -> lookup becomes finished -> cleanup sent -> cleanup_memory_objs releases (cache_engine.py:1403-1435, lmcache_async_lookup_client.py:265-283). no-response lookups never enter it.

scheduler-side state also grows without bound in the same lanes: reqs_status keeps a None entry per aborted lookup (lmcache_async_lookup_client.py:171-174) and aborted_lookups never drains, plus res_for_each_worker entries for partial responses.

To Reproduce

static analysis on main @ 631a59b; i have not built a runtime repro. realistic trigger: with pin=True lookups (the vllm integration path), any exception from a storage backend inside async_lookup_and_prefetch after an earlier tier pinned keys (a remote backend disconnect is the natural candidate), or a response that fails to decode client-side. expected observable symptoms after repeated failures: growing pinned share reported by the allocator, shrinking evictable hot-tier capacity, one warning line per timed-out lookup with no counter anywhere (the 0-hit counter at observability.py:1047 and the timeout warning are indistinguishable from a cold miss on the dashboards), and steady growth of the scheduler-side dicts.

happy to build a failing unit test around the real lookup client/server pair once the maintainers confirm which direction is wanted.

Expected behavior

any lookup that took pins should release them whether or not a response reaches the scheduler: failure paths inside the coroutine should send a 0-hit response (or otherwise mark the lookup finished), the fire-and-forget future should be observed, and aborted lookups should have a drain path that does not depend on a response arriving. distinguishability on the metrics side (timed out vs genuinely 0 hit) would make the failure mode visible at all.

Additional context

  • tests/v1/test_cache_engine_cleanup.py covers cleanup_memory_objs mixed pin state only; nothing pins the no-response lanes
  • no docs mention lookup_timeout_ms semantics
  • searched open issues and PRs for lookup timeout / pinned leak / aborted lookup: nothing adjacent
  • possible directions (not prescribing): a try/except around the coroutine body that responds 0 and releases pins taken so far; observing the run_coroutine_threadsafe future; moving the event DONE update after task.result(); a server-side or scheduler-side reaper for aborted lookups older than some bound