aborted async lookups that never receive a worker response leak pinned memory objects and scheduler-side state
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:733batched_async_contains(lookup_id, keys, pin)pins every matching key (documented atstorage_manager.py:743-746)- the coroutine is fire-and-forget:
cache_engine.py:1391-1401schedules it withasyncio.run_coroutine_threadsafeand 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_callbackispass(storage_manager.py:544-557), so an individual loading-task failure is also unhandledprefetch_all_done_callbacksets the LOADING event to DONE before callingtask.result()(storage_manager.py:574-577), so when a loading task raises, the event is DONE butsend_response_to_schedulerat :653 is never reached
on the scheduler side the abort machinery is response-gated:
lookup_cachetimes out afterlookup_timeout_ms(default 3000,config.py:457-461), logs one warning, returns 0 so vllm recomputes (lmcache_async_lookup_client.py:176-186)cancel_lookuponly adds the id toaborted_lookups(lmcache_async_lookup_client.py:257-259)_cleanup_finished_aborted_lookupsonly drains aborted lookups whosereqs_statusentry 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 theLookupCleanupMsgthat would triggercleanup_memory_objsis never sent- even if a cleanup message were sent,
cleanup_memory_objsearly-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:
- 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
- a loading task raises: event is set DONE at
storage_manager.py:574but the response send at :653 is skipped whentask.result()re-raises inside the done callback. pins leak even though cleanup would have worked - 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.pycoverscleanup_memory_objsmixed pin state only; nothing pins the no-response lanes- no docs mention
lookup_timeout_mssemantics - 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_threadsafefuture; moving the event DONE update aftertask.result(); a server-side or scheduler-side reaper for aborted lookups older than some bound
Source: LMCache/LMCache