Skip to content

[fix] Fix MooncakeStore SSD offload hard_pin detection and master lease TTL - #254

Merged
0oshowero0 merged 1 commit into
Ascend:mainfrom
0oshowero0:fix/mooncake-ssd-offload
Dec 3, 2026
Merged

0oshowero0 merged 1 commit into
Ascend:mainfrom
0oshowero0:fix/mooncake-ssd-offload

Conversation

@0oshowero0

Copy link
Copy Markdown
Collaborator

Summary

Fixes two bugs that prevented MooncakeStore SSD offload (backend.MooncakeStore.offload.enabled: true) from evicting DRAM replicas under the default tq.init() configuration, causing writes exceeding cluster DRAM to fail with NO_AVAILABLE_HANDLE (-200).

Root Cause

  1. hard_pin auto-disable failed on OmegaConf DictConfig (transfer_queue/storage/clients/mooncake_client.py):
    tq.init() passes an OmegaConf DictConfig to MooncakeStoreClient. Checking isinstance(offload_conf, dict) always evaluated to False for DictConfig, so offload_enabled stayed False and hard_pin: null resolved to with_hard_pin = True. Hard-pinned objects are never evicted by Mooncake (Eviction: 0/0).

  2. Hardcoded -default_kv_lease_ttl=999999 blocked DRAM reclamation (transfer_queue/storage/bootstrap/mooncake_bootstrap.py):
    initialize_mooncake_storage() unconditionally passed -default_kv_lease_ttl=999999 (~16.7 minutes), -default_kv_soft_pin_ttl=999999, and --allow_evict_soft_pinned_objects=false to mooncake_master. Even when hard_pin was explicitly set to false and mooncake_client flushed buckets to SSD, mooncake_master refused to release the DRAM replicas until the 999,999 ms lease expired, resulting in OOM (-200) once cumulative writes reached total DRAM capacity.

    Because non-offload eviction is already prevented by with_hard_pin = True and --eviction_high_watermark_ratio=1.0 --eviction_ratio=0.0 (and TransferQueue never enables soft pinning), these three overrides are unnecessary and can be removed in favor of Mooncake's default lease TTL (10 s in Mooncake 0.3.14).

Changes

  • transfer_queue/storage/clients/mooncake_client.py: Check isinstance(offload_conf, Mapping) instead of dict when resolving offload.enabled for hard_pin auto-management.
  • transfer_queue/storage/bootstrap/mooncake_bootstrap.py:
    • Remove -default_kv_lease_ttl=999999, -default_kv_soft_pin_ttl=999999, and --allow_evict_soft_pinned_objects=false from the mooncake_master launch command so Mooncake uses its default lease TTL.
    • Handle offload: null safely (get("offload") or {}).
  • tests/test_mooncake_offload.py: Add unit tests covering with_hard_pin auto-management for both OmegaConf DictConfig and plain dict (including offload: null and explicit hard_pin overrides) and mooncake_master / mooncake_client bootstrap flags.

Verification

Unit Tests & Linters

  • python -m compileall -q transfer_queue tutorial tests: passed
  • python -m pytest -q tests/test_mooncake_offload.py tests/test_mooncake_bootstrap.py tests/test_mooncake_buffer_pool.py tests/test_mooncake_client_thread_context.py tests/test_mooncake_utils.py: 96 passed, 7 skipped
  • pre-commit (ruff, ruff format, mypy, check-license, check-docstrings): all passed

Two-Node RDMA End-to-End Verification

Tested on a 2-node RDMA cluster (mooncake-transfer-engine-cuda13==0.3.14, Rust controller, protocol: rdma, metadata_server: P2PHANDSHAKE, global_segment_size: 512 MiB × 3 segments = 1.50 GiB total DRAM, eviction_high_watermark_ratio: 0.5, eviction_ratio: 0.3), writing 240 × 8 MiB = 1.92 GiB (> 1.50 GiB DRAM) from Node 1 and reading back on Node 2:

Configuration with_hard_pin Max Written SSD Written DRAM Evicted Result
Before (hard_pin: null) True (bug) 100% DRAM 0 MiB 0 MiB Fails with NO_AVAILABLE_HANDLE (-200)
Before (hard_pin: false workaround) False 1.50 GiB (192/240 keys) 256 MiB 0 MiB (default_kv_lease_ttl=999999) Fails with NO_AVAILABLE_HANDLE (-200)
After (hard_pin: null, default tq.init()) False 1.92 GiB (240/240 keys) 768 MiB 512 MiB (64 keys, AllocFail=0) Pass — cross-node kv_batch_get verified 56/56 keys (40 oldest SSD-evicted + 16 recent) bit-exact in 1.47 s; tq.close() cleanly terminated mooncake_client

…se TTL

Two bugs prevented MooncakeStore SSD offload from reclaiming DRAM under the
default tq.init() configuration:

1. MooncakeStoreClient checked isinstance(offload_conf, dict) when deciding
   whether to auto-disable replica_config.with_hard_pin. Because tq.init()
   passes an OmegaConf DictConfig, offload_enabled always evaluated to False
   and objects remained hard-pinned, preventing eviction. Use Mapping instead.

2. initialize_mooncake_storage() unconditionally passed
   -default_kv_lease_ttl=999999 (~16.7 min), -default_kv_soft_pin_ttl=999999,
   and --allow_evict_soft_pinned_objects=false to mooncake_master. Even when
   offload flushed objects to SSD, Mooncake refused to reclaim their DRAM
   replicas until the 999999 ms lease expired, causing NO_AVAILABLE_HANDLE
   (-200) once cumulative writes exceeded cluster DRAM. Remove these obsolete
   overrides and rely on Mooncake's default lease TTL; non-offload eviction is
   already prevented by with_hard_pin=True and eviction_ratio=0.0.

Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-03T03:42:04.523270Z 79af7e3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@0oshowero0

Copy link
Copy Markdown
Collaborator Author

CC @huniu20

@0oshowero0
0oshowero0 merged commit 821e4f5 into Ascend:main Dec 3, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant