Skip to content

[Store] Fence the local disk tier on the first unrecoverable disk error - #4490

Merged
ykwd merged 19 commits into
kvcache-ai:mainfrom
Juhyun-Kim-Memphis:inf-599/disk-fence
Nov 9, 2026
Merged

ykwd merged 19 commits into
kvcache-ai:mainfrom
Juhyun-Kim-Memphis:inf-599/disk-fence

Conversation

@Juhyun-Kim-Memphis

@Juhyun-Kim-Memphis Juhyun-Kim-Memphis commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Problem. When the SSD offload disk dies, the store keeps using it. Every disk failure is reduced to FILE_OPEN_FAIL / FILE_READ_FAIL / FILE_WRITE_FAIL and the errno is dropped, so the store cannot tell a dead device from a full disk or one bad file. Writes fail again on every offload cycle, reads keep failing on every request, and the master keeps handing out the dead disk replicas. In our production incident one NVMe failure (XFS shut down after a log I/O error) caused FILE_OPEN_FAIL for every reader of that store's disk replicas for 52 minutes, until someone drained it by hand.

Fix. Keep the errno and decide at the first failure whether retrying can ever help. If it cannot, fence this store's disk tier only.

errno of the failed syscall action
ENODEV, ENXIO, EROFS, ESHUTDOWN fence
EIO (and block-layer / corruption errnos) check the filesystem once, fence only if the check fails
everything else (ENOSPC, ENOENT, ...) ignore

Both I/O paths keep the errno: PosixFile from the first failed syscall, UringFile from the first failed io_uring completion. A short read or write (pwritev/preadv or an io_uring completion) is not treated as a failure: the rest is submitted again, so the errno comes from the call that really fails. (Found in a production fire drill: an XFS shutdown in the middle of a bucket write first showed up as a short pwritev with no errno, and the fence waited 9.7 s for the next disk access.)

The filesystem check is syncfs() followed by fstat() on a directory fd held open since start-up. We measured this on a 6.8 kernel with XFS on device-mapper (dm-error, XFS shutdown, one bad block under one file, ENOSPC, a 6-leg stripe with one dead leg):

  • After a disk failure, XFS shuts down only when a log write fails, so the first EIO usually arrives while XFS is still up. syncfs() forces the log write, and on a dead device that write fails and shuts XFS down.
  • After a shutdown, fstat() returns EIO, does no I/O and never blocks. With one bad file, XFS stays up and fstat() succeeds, so there is no fence.
  • statfs() cannot be used: it still succeeds after a shutdown. A small sentinel write cannot be used either: on a striped volume it misses the dead leg.

With several offload disks (storage_filepath as a list, #4231) the check covers every disk; a failure does not say which disk it came from, and the master has one LOCAL_DISK segment per store, so one dead disk fences the whole disk tier.

No counters or time windows are involved: each failure is judged on its own against the filesystem's current state. Checks run one at a time; a failure that arrives while one runs is queued and checked right after it, with syncfs if any queued failure needs it, so a write failure's syncfs is not lost behind a read's fstat-only check.

What a fence does (latched until the store restarts):

Related fix in the same path. DrainLocalDiskSegment used to reset the drain latch when the unmount RPC failed (for example, a timeout while the master is still sweeping a large index). The next heartbeat then got SEGMENT_NOT_FOUND, re-mounted the segment and re-registered every object while the master's sweep was still running. On a rig with about 2.9M keys and a 1 s RPC timeout this happened in both rounds and the master lost the index of 62,597–75,840 disk objects. Now the latch stays set, and while draining each heartbeat retries the unmount until the master acknowledges it (the master already treats an already-unmounted segment as success). The heartbeat never re-mounts while draining. This changes the drain contract of #3316: a failed UnmountLocalDiskSegment no longer unlatches the drain, and the store does not resume until the master acknowledges the unmount (pinned by DrainUnmountFailureKeepsLatchAndRetries).

New gauge: mooncake_ssd_disk_fenced (0/1). Each fence logs one line with the op, the errno, the check result and the path.

Scope: errnos are reported by bucket_storage_backend (the default backend). The file-per-key and offset-allocator backends do not report them yet, so they never fence; this is noted in the docs.

Docs: a troubleshooting entry for action=disk_fence in docs/source/deployment/ssd/ssd-offload.md.

Out of scope: per-key recovery from a single bad file (#3889; this PR does not fence in that case), and a device that hangs without returning an errno.

Module

  • Mooncake Store (mooncake-store)
  • Documentation (docs)

Type of Change

  • Bug fix

How Has This Been Tested?

Test commands:

# Release build, BUILD_UNIT_TESTS=ON
./posix_file_test && ./file_storage_test && ./storage_backend_test && ./ssd_metrics_test \
  && ./file_storage_promotion_test && ./offload_on_evict_test && ./master_service_ssd_test \
  && ./rpc_timeout_test && ./promotion_on_hit_test

Test results:

  • Unit tests pass. Merged with main at 52f989e0, in an amd64 container: every test in the suites above passes except 8 io_uring tests, which cannot create a ring there (io_uring_setup returns ENOSYS); CI covers them on a real kernel. Before the last merge, on a real kernel: 277/277.
  • Manual testing done

New tests:

  • the errno classification;
  • errno capture in PosixFile;
  • fence on ENODEV, and on EIO when the filesystem check fails;
  • no fence on EIO when the check passes, and none on ENOSPC;
  • after a fence, reads (whole values and byte windows) short-circuit, the segment is unmounted on InProcMaster and the heartbeat does not re-mount;
  • a failure that arrives during a running check is checked after it (a write failure queued behind a read's check gets syncfs), and the checking slot is released afterwards;
  • a fence NACKs an offload task carried across a real bucket deferral, and leaves the carry map and the pool empty;
  • with two offload roots, the check opens and checks each root (checking the list as one path gives ENOENT);
  • the drain latch survives a failed unmount RPC and the unmount is retried;
  • short pwritev/preadv and short io_uring completions continue to the real errno (RLIMIT_FSIZE gives EFBIG, an inaccessible page gives EFAULT); a failed io_uring completion keeps its errno, and the io_uring read leg reports it to the observer.

The latch test fails on main as is. The other new tests use the new API and do not compile on main. The short-I/O and io_uring tests each fail on 75fe664c. The queued-check and carried-task tests each fail with their fix reverted.

Manual: the errno behavior above was measured with deterministic fault injection (dm-error / dm-flakey / XFS shutdown / dm-stripe) on a 6.8 kernel. End-to-end results with master + 3 stores on fault-injected disks are in the comments.

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh (clang-format 20)
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have added tests to prove my changes are effective
  • I have updated the documentation
  • For changes >500 LOC: I have filed an RFC issue — not filed: this is a bug fix, not an architectural change. The diff is +1658/−66: about 440 lines of non-test code (570 with comments), about 1080 of tests, and 12 of docs.

AI Assistance Disclosure

  • AI tools were used (specify below)

Claude (Anthropic) helped trace the code paths, run the kernel errno measurements, write the change and its tests, and run the verification. The submitter is responsible for the change.

A dead offload disk today keeps being used: every failed read or write
returns a FILE_* error code that cannot tell a dead device from a short
write or a full disk, the errno is dropped, and the heartbeat keeps
taking offload work and re-mounting the LOCAL_DISK segment.

Keep the errno and decide at the first failure:

- StorageFile records the errno of its first failed syscall
  (sys_errno()); PosixFile sets it for write/pwritev/read/preadv/
  fdatasync. Short reads and writes stay logical (errno 0).
- StorageBackendInterface gains SetDiskErrorObserver (default no-op).
  BucketStorageBackend reports open/pwritev/fdatasync/write/read/preadv
  failures with their errno.
- FileStorage classifies the errno inline on the failing thread:
  ENODEV/ENXIO/EROFS/ESHUTDOWN fence; EIO and the block-layer and
  corruption errnos run one filesystem check (syncfs to force the XFS
  log, then fstat on a held offload-dir fd, which fails with EIO exactly
  when XFS is shut down) and fence only if it fails; everything else
  (ENOSPC, ENOENT, ...) is ignored. No counters or time windows.
- A fence is latched for the process lifetime: reads short-circuit and
  offload stops at once; the heartbeat (woken immediately) disables
  offloading and unmounts the segment through the drain latch.
- The drain latch is no longer reset when the unmount RPC fails. While
  draining, each heartbeat retries the unmount until the master
  acknowledges it (the master treats an already-unmounted segment as
  success) and never re-mounts.
- New gauge mooncake_ssd_disk_fenced (0/1).
@Juhyun-Kim-Memphis
Juhyun-Kim-Memphis marked this pull request as ready for review October 7, 2026 06:47
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

End-to-end results on a rig (master + 3 stores on loop/device-mapper disks with XFS, RDMA, paced writers and readers; faults injected on store a only), build 54952130:

Scenario Expected Result fault → first failure → fence → unmount acked
XFS forced shutdown fence ✅ 0 → 0.027 s → 0.030 s → 0.367 s
whole device returns EIO (dm-error) fence ✅ 0 → 0.562 s (fdatasync EIO) → 0.569 s → 0.964 s
one bad bucket file (error range under one file) no fence ✅ only that bucket's 500 keys fail; 0 failures outside it
ENOSPC no fence ✅ writes fail, keys already on disk still read
6-leg stripe, one leg dead fence once XFS shuts down ✅ fence 18–29 s after the fault, within 3 ms of the shutdown
drain with a 1 s RPC timeout (≈3M keys) latch holds ✅ RPC times out at 1.03 s, retry acked at 2.9 s, no re-mount, no lost index (before the fix: 62,597 / 75,840 objects lost)
fence while the unmount RPC times out (2.4M keys) latch holds ✅ fence 0.039 s, unmount timed out, retry acked at 11.0 s, no re-mount

In every fence case:

  • other clients' disk read errors stop 0.3–0.4 s after the fence (2.0 s with the slow unmount). On main they kept failing for the whole 4-minute run.
  • the master stops assigning offload work to the store.
  • the store's memory segment and the other stores are unaffected: all their puts and gets succeed, ping p99 stays at 0.2–0.5 ms, and no client expires.

Two notes:

  • With one dead leg in a stripe, XFS stays up until a log write lands on that leg, and there is no fence until then. In our runs that took 18–29 s.
  • mooncake_ssd_disk_fenced is not exported until the first fence, so before that it is absent rather than 0. I will push a one-line change so that it reads 0 from start-up.

Follow-up to the disk fence, from review:

- ApplyDiskFence now sends one OffloadObjectHeartbeat with offloading
  disabled before the unmount (skipped if a drain already unmounted).
  The unmount drops the master's offload queue for this store but not
  the source-replica references its tasks hold, so those memory replicas
  stayed pinned until the master's TTL reaper (600 s). The heartbeat
  makes the master release them and stop enqueuing; it is best effort.
- The filesystem check runs syncfs only after a write-path failure
  (pwritev, fdatasync, write, open). A failed read leaves the log
  nothing to write (read failures alone never shut XFS down on the rig),
  and one bad file otherwise caused a whole-filesystem flush on every
  failed read. Read failures check with fstat only.
- If the offload dir fd could not be opened, the check falls back to
  stat on the path instead of silently never fencing.
- mooncake_ssd_disk_fenced is set to 0 at construction, so the series
  exists before a fence.
- The unmount retry logs failures at WARNING; the vector_read and
  vector_write failure logs carry the errno; disk_error_not_fenced
  names the check that ran (fstat or syncfs+fstat).

Tests: the fenced scenarios now queue a real offload task and check that
the master released it (Upsert succeeds) instead of checking a local
flag; the fenced OffloadObjects assertion uses a key with a memory
replica, so it fails without the fence; read failures are checked
without syncfs and write failures with it; the gauge is exported before
any failure.
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up commit, 75fe664, from an internal review:

  • The fence now hands queued offload work back: ApplyDiskFence sends one
    OffloadObjectHeartbeat(false) before the unmount (skipped if a drain already unmounted).
    The unmount dropped the master's queue but kept the tasks' source-replica refcounts, so
    those memory replicas stayed pinned until the 600 s TTL. Rig: of 1,200 keys written to the
    fenced store's memory in the 12 s before the fault, 976 refused Upsert before, 0 after.
  • syncfs runs only after write-path failures; read failures check with fstat only (reads
    alone never shut XFS down here, and one bad file cost a whole-fs flush per failed read).
  • stat(path) fallback if the dir fd failed to open; the gauge starts at 0; unmount-retry
    failures log at WARNING; vector_read/vector_write failure logs carry errno.
  • Tests assert the master-side release instead of a local flag; each new assertion fails
    with its fix reverted. Unit suites and the rig E2E scenarios re-run green.

@he-yufeng he-yufeng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the full diff against main and walked the new paths. The design holds up, and the test matrix is unusually complete: dead-fs fences, live-fs control, ENOSPC/ENODEV boundaries, concurrent-check dedup, drain retry, fenced offload never reaching the backend.

What I verified on the mechanism side:

  • Errno really is dropped on main today. The StorageFile::record_sys_errno plumbing covers every PosixFile failure point, and OpenFile reporting "open" closes the FILE_OPEN_FAIL case from the incident.
  • The fence abort in OffloadObjects composes with the existing sweep correctly: buckets after the break never enter all_bucket_keys, so the end-of-cycle sweep pushes their tasks to failed_tasks and NotifyOffloadSuccess releases them together with their source replica refs. No task is stranded.
  • UnmountLocalDiskIfPending's retry is safe against the master: master_service.cpp:8527 returns success for an unregistered client, so a first response that was lost followed by a retry is benign.
  • The heartbeat wake (state change under heartbeat_wake_mutex_, then notify_all, predicate re-checked in wait_for) cannot lose a wakeup.
  • ApplyDiskFence releasing the queued offload tasks via OffloadObjectHeartbeat(false) before the unmount is the right order: the unmount sweep alone would leave those tasks pinning their memory replicas until the TTL reaper.

Two things to address, the first one real:

  1. The io_uring build never fences. UringFile has no record_sys_errno (uring_file.cpp is untouched), and WriteBucket's write_aligned failure returns before the datasync step that carries that path's only NotifyDiskError. The BatchLoad read leg likewise reports nothing when OpenFile yields an UringFile. So under USE_URING a dead device is silent on every leg except a failed fdatasync after a successful write. If posix-only coverage is the intended scope here, please say so in the description and file the uring half as a follow-up; otherwise UringFile needs the same errno plumbing plus a notify on the write_aligned failure.

  2. The drain contract from #3316 changes here: on main, a failed UnmountLocalDiskSegment RPC unlatches draining_ and the store resumes; with this PR the latch stays and the heartbeat retries until the master acks. Fail-closed is the right call and DrainUnmountFailureKeepsLatchAndRetries pins it, but it is a shipped-behavior change beyond fencing, so it deserves a line in the PR description for whoever owns that path.

One small question, not a blocker: CheckFilesystem runs syncfs inline on the failing I/O thread. On dm-error that fails fast, as you measured; on a device that errors the triggering syscall quickly but wedges writeback, syncfs could park that thread for a while. That thread is already doomed in that world, so I would not gate on it, but a comment stating the assumption would save the next reader a wonder.

Overall the right shape: judge each failure once, fail closed, and reuse the drain path instead of inventing a second deregistration.

PosixFile::vector_write treated a short pwritev as a failure with no
errno. When an XFS shutdown landed in the middle of a bucket write, the
kernel returned a partial count, errno stayed 0, and the disk fence
classified the failure as logical: it fenced only on the next disk
access, 9.7 s later in a production drill. vector_read had the same
shape (a buffered read over a bad block comes back short, no errno).

A short count is not an error. Both functions now continue with the
remaining bytes at the advanced offset (on a copy of the caller's
iovecs), retry EINTR, and record errno from the call that really fails,
which on a dead disk is EIO. vector_write fails without errno only on a
0-byte return, so it cannot loop forever. vector_read still returns a
short count, but now only at EOF, so callers' size checks are unchanged.
With use_uring, the disk fence saw nothing from io_uring: UringFile kept
no errno, and the BatchLoad read leg and the WriteBucket write_aligned
leg reported no failure to the observer.

- The ring records the errno of the first failed CQE of each call
  (-cqe->res); UringFile keeps it as sys_errno() after a failed call,
  as PosixFile does for a failed syscall.
- A short completion is continued, as pwritev/preadv now are: io_uring
  completes a read or write short, without the errno, when it fails
  after moving some bytes. Chunked and vector reads/writes and
  batch_read track each SQE's result and submit the rest of a short
  one. A read ends at EOF (0 bytes, or a stop off a 4 KiB boundary,
  where an O_DIRECT read could not resume).
- BatchLoad's io_uring read failure reports "read" and WriteBucket's
  write_aligned failure reports "write" to the disk-error observer.
  LoadBucketMetadata already reported its read; it now has the errno.
  (BucketStorageBackend opens bucket files for writing as PosixFile
  even with use_uring, so its writes already reported pwritev.)

Error codes returned by the ring are unchanged.
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

Thanks for the careful read. All three points are addressed in new commits on top of 75fe664 (head is now 4ab8d5c); each new test fails on 75fe664.

  1. io_uring — 63db58f. The ring records -cqe->res of the first failed completion and UringFile keeps it as sys_errno(); BatchLoad's io_uring read reports read and write_aligned reports write. Short completions are continued too, since io_uring returns the partial count and drops the errno when a request fails midway. One correction to the premise: BucketStorageBackend::OpenFile opens write files as PosixFile even with use_uring, so bucket writes already reported pwritev/fdatasync; the gap was the read leg. Tests: UringFailedCqeKeepsErrno, UringShortWriteContinuesToTheRealErrno, UringReadIsShortOnlyAtEof, BucketBackendReportsUringReadErrno. Rig with use_uring, whole device on dm-error: before, the first failure was a silent read (batch CQE error, nothing reported); now it is reported with errno=5, and the fence follows on the next write-path failure (reads only run fstat, by design).
  2. Drain contract — added to the description: a failed UnmountLocalDiskSegment no longer unlatches the drain; the store does not resume until the master acks the unmount (DrainUnmountFailureKeepsLatchAndRetries).
  3. syncfs — 4ab8d5c adds the comment in CheckFilesystem.

One more fix from a production fire drill — 8e7acd4. An XFS shutdown in the middle of a bucket write first showed up as a short pwritev, which was failed without an errno, so the fence waited 9.7 s for the next disk access. vector_write/vector_read now continue a short count, so the next call reports the real errno.

  • Deterministic (shutdown + strace-forced short pwritev): before, an errno-less failure and the fence 10.0 s later at open; after, the continuation pwritev (offset 4096) returns EIO and logs action=disk_fence, op=pwritev, errno=5 at that failure.
  • 42 real shutdowns during offload bursts (21 per build): before, 5/21 started with an errno-less pwritev and fenced ~10 s later (16/21 at the first failure); after, 21/21 fenced at the first failure (max 5.2 ms).

Unit suites: 247/247.

Review fixes for the short I/O and io_uring errno commits.

- The iovec helpers that continue a short pwritev/preadv move to
  src/iovec_cursor.h (mooncake::detail) and get direct tests: a stop
  inside an iovec, at a boundary, across several boundaries, and empty
  iovecs, plus a fake-pwritev loop over every short count. The kernel
  test that stops inside the second iovec could not see where the
  continuation resumed (it writes nothing at the limit), so it is
  renamed to what it checks: the real errno and unchanged caller iovecs.
  PosixFile's loop is unchanged.
- io_uring: a short completion is continued in a loop of single SQEs
  instead of recursing through submit_rw. Each call resets the CQE errno
  before the ring check, so a call on a ring that failed to reinitialize
  does not inherit the previous call's errno.
- Tests: the vector_read EBADF check uses a new file (the first errno
  wins, so it could not fail); batch_read and vector_read short
  completions are covered; the page-size and io_uring RLIMIT_FSIZE
  tests skip where their premise does not hold; a stale comment is
  corrected.
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

Pushed ad3dc7d (review follow-up, no behavior change on the posix path):

  • The iovec-advance helpers for continuing a short pwritev/preadv move to src/iovec_cursor.h and get direct tests (stop inside an iovec, at/across boundaries, empty iovecs, every short count); the RLIMIT test could not see where the continuation resumes, so it is renamed to what it checks.
  • io_uring: a short completion is continued in a loop of single SQEs instead of recursing through submit_rw; the CQE errno is reset before the ring check.
  • Tests: non-vacuous EBADF check, batch_read/vector_read short completions, skips for non-4K pages and kernels that do not apply RLIMIT_FSIZE to io_uring writes.
  • 252/252 across the nine suites; a mutant that does not advance iov_base now fails 4 of the 5 new tests.

typos reads 'wronly' as a misspelling of 'wrongly' and fails CI. Rename
the write-only descriptors in posix_file_test to write_only*, and drop an
internal scenario label from a file_storage_test comment.
The comment said syncfs runs only for write-path failures, but the code
skips it only for reads (preadv, read); open, which may be creating a
file, still syncs. Describe what the code does.
Add a troubleshooting entry for action=disk_fence: which errnos fence,
what a fence stops, the mooncake_ssd_disk_fenced gauge, that it lasts
until restart, and that only bucket_storage_backend reports disk errors.
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Oct 14, 2026
@Juhyun-Kim-Memphis

Juhyun-Kim-Memphis commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Pushed bdb8c54:

Merged with current main, the branch passes the same 9 suites, 252/252.

@ykwd @Aionw would you have time to take a look? No code owner has reviewed yet.

Comment thread mooncake-store/src/file_storage.cpp Resolved
# Conflicts:
#	mooncake-store/include/file_storage.h
#	mooncake-store/tests/file_storage_test.cpp
A failure that found a filesystem check running returned without a check
of its own. If a read failure's fstat-only check was running when a write
failed, the write's syncfs never ran: XFS was still up, fstat passed, and
neither failure fenced, although syncfs could have forced the failing log
write that shuts XFS down.

Now such a failure is queued, and the thread running the check checks it
next. Queued failures share one check, which runs syncfs if any of them
needs it. The checking slot is released under the same lock that queues,
so no failure is left behind.
kvcache-ai#3006 (merged from main) keeps the tasks of keys the bucket backend
deferred to its ungrouped pool, and consumes them on the next offload
cycle. A fenced store runs no further cycle, the master's queue no longer
holds those tasks, and the unmount does not release them, so their memory
replicas stayed pinned until the master's TTL reaper.

ApplyDiskFence now NACKs them after handing back the queued work, and
clears the pool, the same way the key-count limit does when it stops
offloading.
DiskFenceQueuedCheckReleasesTheCheckingSlot used private FileStorage
members in its TEST_F body. FileStorageTest is a friend, but a TEST_F body
is a subclass of the fixture and friendship is not inherited, so the test
did not compile. Go through static helpers on the fixture, as IsDraining
does.
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

Pushed a4016162, merged with current main (the PR was conflicting):

  • Review fix (c0dff6d6, @fcczzz's thread): a failure that arrives during a running filesystem check is now queued, and the thread running the check checks it right after, with syncfs if any queued failure needs it. A write EIO queued behind a read's fstat-only check now gets its syncfs.
  • Needed by the merge (c2263fa1): [Bug]: [SSD] Offload keys deferred to the ungrouped pool lose their tasks — NACKed at deferral, silently dropped next cycle, never written to SSD #3006 carries the tasks of keys deferred to the ungrouped pool over to the next offload cycle. A fenced store runs no next cycle, and the unmount does not release those tasks, so their memory replicas stayed pinned until the TTL reaper. ApplyDiskFence now NACKs them and clears the pool, the same way the key-count limit does.
  • a4016162 fixes the compile of one new test (its TEST_F body used private members).

Verification on the merged branch (amd64 container): the nine suites in the description pass, except 7 io_uring tests from main that do not skip when io_uring is unavailable (the container could not create a ring). Each new test fails with its fix reverted: dropping the queued failure fails DiskFenceChecksWriteFailureQueuedBehindReadCheck, keeping the checking slot fails DiskFenceQueuedCheckReleasesTheCheckingSlot, and removing the carried-task NACK fails the carried_released assertion in both fence scenarios.

@fcczzz @ykwd could you take another look?

…al deferral

Replaces the carried-task release of c2263fa with the version that has
run on our fork since kvcache-ai#3006 was backported there:

- NackCarriedOffloadTasks() runs before the queue hand-back, and clears
  the ungrouped pool even when no task is carried.
- The OffloadObjects fence abort comment says that carried keys stay
  carried until that NACK.
- DiskFenceNacksCarriedOffloadTasks defers a real key to the pool (bucket
  limit 2, one key) before the fence, instead of planting a task in the
  carry map, and checks that the task is released and that the carry map
  and the pool are empty.
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

Pushed 1e07f2fa, which replaces yesterday's carried-task release (c2263fa1) with the version that has run on our fork since #3006 was backported there. Same behavior, with three differences:

  • the NACK lives in NackCarriedOffloadTasks(), runs before the queue hand-back, and clears the ungrouped pool even when no task is carried;
  • the fence-abort comment in OffloadObjects says that carried keys stay carried until that NACK;
  • DiskFenceNacksCarriedOffloadTasks defers a real key to the pool before the fence (instead of planting a task in the carry map) and checks that the task is released and the carry map and the pool are empty. It fails with the NACK call removed.

On a real kernel the nine suites in the description pass, 267/267.

@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

CI note on 1e07f2fa: build-wheel-efa (cuda, 3.12) failed in "Install CUDA Toolkit", before any build step, because NVIDIA's apt mirror was mid-sync (developer.download.nvidia.com/.../ubuntu2204/x86_64/Packages: File has unexpected size (3134436 != 3115357). Mirror sync in progress?). The cuda13 leg was cancelled with it while still waiting for a runner. Both legs passed on the previous head a4016162. I cannot re-run jobs on this repository; could someone with access re-run the failed ones?

# Conflicts:
#	mooncake-store/include/file_storage.h
#	mooncake-store/src/file_storage.cpp
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

Merged current main again (b96c0dc9): #4272 and #4313 added code at the same places in file_storage.{h,cpp}, and both sides are kept. SSD prefetch goes through FileStorage::BatchLoad, so it stops reading once the disk tier is fenced. On a real kernel the nine suites in the description pass on the merged branch. This push also re-runs the CUDA wheel job that failed on the NVIDIA mirror last time.

@fcczzz @ykwd when you have time, could you take another look?

@fcczzz fcczzz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

# Conflicts:
#	mooncake-store/tests/file_storage_test.cpp
kvcache-ai#4988 (merged from main) added FileStorage::BatchLoadSpans, a second
disk read path next to BatchLoad. Its failures already reach the fence
(both go through BucketStorageBackend::ReadBucketValues, which reports
the errno), but after a fence it still read the dead disk, while BatchLoad
fails at once. Fail it the same way.
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

Thanks for the approval, @fcczzz.

Merged current main again (7e3292a9, a test-file conflict where both sides added tests). One fix came with it, dde0f9cd: #4988 added a second disk read path, FileStorage::BatchLoadSpans. Its failures already reach the fence (it shares BucketStorageBackend::ReadBucketValues with BatchLoad), but after a fence it still read the dead disk. It now fails at once, like BatchLoad; DiskFenceEioOnDeadFilesystemFencesDiskTier checks it and fails with the guard removed. On a real kernel the nine suites in the description pass, 277/277.

@ykwd could you take a look as a mooncake-store code owner?

@github-actions github-actions Bot added the size/L 1001+ changed lines (additions + deletions) label Nov 3, 2026

@ykwd ykwd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Could you resolve the conflicts?

# Conflicts:
#	mooncake-store/include/storage_backend.h
#	mooncake-store/src/file_storage.cpp
#	mooncake-store/src/uring_file.cpp
#	mooncake-store/tests/posix_file_test.cpp
#	mooncake-store/tests/storage_backend_test.cpp
…isks

kvcache-ai#4231 (merged from main) lets storage_filepath list several disk roots.
The filesystem check opened and stat-ed storage_filepath as one
directory, so with "a,b" it got ENOENT, which never fences: a dead disk
went unfenced.

The client now holds one directory fd per root (ResolveOffloadDiskPaths)
and the check runs syncfs (for write failures) and fstat on each, with a
stat fallback for a root whose fd did not open. A failure does not say
which disk it came from, and the master has one LOCAL_DISK segment per
client, so any dead root fences the whole disk tier. An errno that does
not mean a dead filesystem (ENOENT on a missing root) no longer hides one
that does on another root.

Test: two live roots get one fd each and the real check passes; with the
list stat-ed as one path it returns ENOENT. Docs: one dead disk fences
the whole SSD tier.
@Juhyun-Kim-Memphis

Copy link
Copy Markdown
Contributor Author

@ykwd thanks, conflicts resolved: merged main at 52f989e0 (4daca3f1, resolution only), plus one fix the merge needed (80d3a1a0).

Built and tested in an amd64 container: everything in the description's suites passes except 8 io_uring tests that cannot create a ring there (ENOSYS); CI will cover those on a real kernel.

@ykwd
ykwd merged commit 48aa86c into kvcache-ai:main Nov 9, 2026
32 checks passed
jfeng18 added a commit to jfeng18/Mooncake that referenced this pull request Nov 9, 2026
* upstream/main: (28 commits)
  [Store] Remove unreachable dead code in reserved OpLog paths (kvcache-ai#5043)
  [Store][BUGFIX]: Avoid repeated NoF cleanup for unregistered buffers (kvcache-ai#5301)
  [Store] Fence the local disk tier on the first unrecoverable disk error (kvcache-ai#4490)
  [Store] Add opt-in aligned O_DIRECT bucket writes (kvcache-ai#4820)
  [Store] posix support Read DFS replicas straight into host buffers (kvcache-ai#5201)
  [TENT] Pipeline RDMA slice preparation with worker posting (kvcache-ai#5277)
  [TE] HipTransport: submit copies asynchronously, one stream and event per device (kvcache-ai#4953)
  [Misc] Add staryxchen as a HIP transport code owner (kvcache-ai#5351)
  [Doc] nvlink_intra works over PCIe P2P, not only NVLink (kvcache-ai#5266)
  [Bugfix][TENT] Propagate io_uring staging copy failures (kvcache-ai#5335)
  [Bugfix][TENT] Make UB batch submission all-or-nothing (kvcache-ai#5274)
  Add store rs tone tests (kvcache-ai#5282)
  [EP] Validate XPU Buffer constructor arguments (kvcache-ai#5329)
  [EP] Decouple PG builds and add TCPStore bootstrap (kvcache-ai#5312)
  [Bugfix][PG] Serialize RPC socket operations and drain shutdown (kvcache-ai#5098)
  [EP] Enable the native XPU EP over RDMA (kvcache-ai#5207)
  [Store] Use the AWS default credential chain when S3 static keys are unset (kvcache-ai#5303)
  [Bugfix][Store] Register dummy query RPC handlers in mooncake_client (kvcache-ai#5200)
  [Store] Preserve variadic RPC compatible fields with NDEBUG (kvcache-ai#5269)
  [TransferEngine] Avoid false CQ timeout diagnostics after idle periods (kvcache-ai#5281)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci size/L 1001+ changed lines (additions + deletions) Store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants