Skip to content

[Store] Reopen DFS shard once on POSIX I/O failure before surfacing error - #4512

Merged
ykwd merged 1 commit into
kvcache-ai:mainfrom
codenaut-919:dfs-supports-write-fail-reopen-and-read-fail-clear-master-metadata
Oct 14, 2026
Merged

ykwd merged 1 commit into
kvcache-ai:mainfrom
codenaut-919:dfs-supports-write-fail-reopen-and-read-fail-clear-master-metadata

Conversation

@codenaut-919

@codenaut-919 codenaut-919 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

In DFS filesystem shard mode, each shard is a preallocated fixed-size file (dfs_shard_NNNN.data) whose fd is opened on first use and cached for long-lived reuse. When the fd goes stale underneath (e.g. NFS ESTALE, a reclaimed handle), the cached fd keeps failing every pwritev/preadv even though the underlying file is fine.
Before this change the backend surfaced the I/O error on the first hard failure and never touched the cached fd. So once a shard's fd went stale, every subsequent read/write to that shard reused the same bad fd and kept failing until the process restarted — amplifying a single stale fd into an outage for every key mapped to that shard.

what's changed

Add a single-shot reopen-and-retry on the DFS shard read/write paths(only posix mode): when WriteAt/ReadAt returns a hard error, close and reopen the shard's fd inside the per-shard critical section and retry the I/O exactly once; only if the retry also fails is the error surfaced.

  • BatchWrite:retry WriteAt once when write failed (only when SupportsFdReopen()).
  • ReopenShardLocked: requires the caller to hold shard.mutex; closes the old fd, sets it to -1, reopens via ValidateAndOpenShardFile.
  • Reopen reuses ValidateAndOpenShardFile: checks file size == shard capacity first, then canonical root/path, preventing O_CREAT from resurrecting a deleted shard as an empty file.
  • Logs WARNING when a reopen is triggered, ERROR when the reopen itself fails.

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Mooncake Conductor (mooncake-conductor)
  • Reshard (mooncake-reshard)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Test commands:

cmake --build build --target dfs_posix_test -j
ctest --test-dir build -R dfs_posix_test --output-on-failure

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

@codenaut-919
codenaut-919 force-pushed the dfs-supports-write-fail-reopen-and-read-fail-clear-master-metadata branch from 1a5da28 to 8e8a2c3 Compare October 10, 2026 03:37
@codenaut-919
codenaut-919 force-pushed the dfs-supports-write-fail-reopen-and-read-fail-clear-master-metadata branch from 8e8a2c3 to cb8fabb Compare October 10, 2026 06:57

@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. The reopen and retry paths are serialized correctly with shard I/O, and retries remain bounded.

@ykwd
ykwd merged commit 4549d55 into kvcache-ai:main Oct 14, 2026
25 checks passed
@codenaut-919
codenaut-919 deleted the dfs-supports-write-fail-reopen-and-read-fail-clear-master-metadata branch October 14, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants