[Bugfix][KVConnector][Mooncake] Close MooncakeDistributedStore on connector teardown (#45206)
Signed-off-by: Dao Le <Dao007forever@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -153,6 +153,21 @@ class MooncakeStoreConnector(KVConnectorBase_V1, SupportsHMA):
|
||||
else:
|
||||
self.connector_worker = MooncakeStoreWorker(vllm_config, kv_cache_config)
|
||||
|
||||
def shutdown(self):
|
||||
"""Release connector resources on teardown.
|
||||
|
||||
Closes the worker's MooncakeDistributedStore handle so its
|
||||
TransferEngine and RDMA registrations are released. Invoked from the
|
||||
engine's explicit shutdown path and as a backstop from ``__del__``;
|
||||
a no-op on the scheduler role, which holds no store handle.
|
||||
"""
|
||||
worker = getattr(self, "connector_worker", None)
|
||||
if worker is not None:
|
||||
worker.close()
|
||||
|
||||
def __del__(self):
|
||||
self.shutdown()
|
||||
|
||||
# ============================================================
|
||||
# Scheduler-side methods
|
||||
# ============================================================
|
||||
|
||||
@@ -1426,6 +1426,22 @@ class MooncakeStoreWorker:
|
||||
return self.kv_send_thread.get_kv_events()
|
||||
return []
|
||||
|
||||
def close(self) -> None:
|
||||
"""Release the MooncakeDistributedStore handle on teardown.
|
||||
|
||||
Closing the store frees its TransferEngine, the registered RDMA
|
||||
buffers, and the connection to the master server. Idempotent so it is
|
||||
safe to call from both the explicit shutdown path and ``__del__``.
|
||||
"""
|
||||
store = getattr(self, "store", None)
|
||||
if store is None:
|
||||
return
|
||||
self.store = None
|
||||
try:
|
||||
store.close()
|
||||
except Exception as e:
|
||||
logger.warning("Error closing MooncakeDistributedStore: %s", e)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# Lookup Key Server
|
||||
|
||||
Reference in New Issue
Block a user