Skip to content

mds: don't ack dirfrag replicas whose inode isn't replicated to the peer - #73264

Merged
vshankar merged 4 commits into
ceph:mainfrom
anthonyeleven:wip-mds-rejoin-ack-replica
Nov 26, 2026
Merged

vshankar merged 4 commits into
ceph:mainfrom
anthonyeleven:wip-mds-rejoin-ack-replica

Conversation

@anthonyeleven

@anthonyeleven anthonyeleven commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: https://tracker.ceph.com/issues/80407

A surviving (active) MDS can abort in MDCache::handle_cache_rejoin_ack() on ceph_assert(isolated_inodes.empty()) while peer ranks are in up:rejoin. This is tracker 80407, the same assert as 62036 and 50821, and distinct from 80402 and 54840.

The crash starts on the recovering rank. When it processes a surviving peer's strong rejoin for a fragmented directory that it does not have in cache, it invents a single frag_t() dirfrag and records the peer as a replica of it. After it fetches the inode, opened_undef_inode() → CInode::force_dirfrags() splits that dirfrag, and CDir::split() copies the replica map onto every leaf, so the peer is now recorded as a replica of leaves it never held. If the peer then trims the directory and sends a cache expire before the recovering rank sends its acks, the expire removes the peer from the inode and from the leaves it actually had, but the remaining leaves keep the stale replica. The 2014 sweep in handle_cache_expire() only runs when the named dirfrag is missing, so it doesn't catch this. rejoin_send_acks() then acks those leaves to the peer without the inode, the peer builds an unconnected dirfrag that nothing in the ack links, and the assert fires. The deferral from #52648 doesn't help, because it keys on rejoin_done, which is null on an active survivor.

A dirfrag replica cannot exist without an inode replica, so acking a dirfrag to a peer we don't record as a replica of its inode is never correct. This drops such stale replicas in rejoin_send_acks() instead of acking them, for inodes we are authoritative for. Base inodes, inodes we are not authoritative for (the subtree-root case the in-tree FIXME describes) and subtree-root dirfrags are left alone. Subtree roots are known from the subtree map after replay and are never invented and split, and the walk can reach one before the "peer missed MDentryLink" fix-up has run for its inode. The check doesn't rely on replica nonces, which are unreliable after a split.

The race window is short, so this also adds a dev-only option, mds_debug_rejoin_ack_delay (default 0), that defers rejoin_send_acks() with a timer while the rank keeps processing messages. The new test in qa/tasks/cephfs/test_rejoin.py, run in fs:functional, uses it: a fragmented directory one level below an export-pinned directory, a survivor holding an ordinary replica of its inode and one leaf, no client caps and no subtree root at or below it; fail the auth rank, and drop the survivor's cache once the recovering rank has split the directory. Under vstart_runner it failed 3 of 3 runs without the fix (the survivor aborted on the assert) and passed 3 of 3 with it. It has not run under teuthology yet.

Reproduced on 18.2.8 with three active ranks and the delay backported. Stock crashed the survivor on the assert. With the fix, the recovering rank logged dropping 26 stale leaf replicas instead of acking them, the survivor stayed up, and all ranks went active.

@vshankar @batrick @xiubli

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

Signed-off-by: Anthony D'Atri [email protected]
Assisted-by: Claude Opus-5.5

@github-actions

Copy link
Copy Markdown

Config Diff Tool Output

+ added: mds_debug_rejoin_ack_delay (mds.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

/config check ok

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@vshankar could you assign a CephFS reviewer for this one?

@vshankar

vshankar commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@salieri11 - can you please review this? (the weak/strong rejoin code paths is probably fresh in your memory)

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix looks sound... but no yaml runs qa/tasks/cephfs/test_rejoin.py :(

@anthonyeleven please fix up that bit.

return ino
return None

def test_rejoin_ack_isolated_inode(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this reliably reproduces the issue. Let me play around with this a bit more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. It hasn't run under teuthology yet, and it only asserts that the survivor stays up, so a run that misses the window passes.

On 18.2.8 the crash needed two things:

  • X fully cold on the recovering rank: one level below the pinned directory, with nothing replayed for it.
  • The survivor trimming the whole path down to X, not just X's leaf, inside the ack delay.

The test gets the first from flush journal before the fail. It aims at the second with a fixed 8 s sleep after up:rejoin, then cache drop 0. Those are the two places I'd expect it to miss.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reworked test now reproduces it. Under vstart_runner, 3 of 3 runs failed without the fix (the survivor aborted on the assert) and 3 of 3 passed with it. What changed and the numbers are in #73264 (comment).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for revising the version. I will have a look.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

@vshankar fa58b1c adds qa/suites/fs/functional/tasks/rejoin.yaml, so fs:functional runs test_rejoin. That suite's cluster has the four MDS daemons the test needs.

@anthonyeleven
anthonyeleven force-pushed the wip-mds-rejoin-ack-replica branch from fa58b1c to 84fb53c Compare November 6, 2026 17:44
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

Pushed a reworked test, folded into the one qa commit. The old version couldn't reach the race:

  • Its _wait_subtrees calls named one rank but listed only some of that rank's subtrees, so they never matched.
  • Pinning X's child back to the auth rank left an aux subtree, so the new rank replayed X from its subtree map instead of inventing it.
  • The client's caps on X and its files made the new rank open X from disk before rejoin.
  • A fixed sleep decided when the survivor trimmed, and an expire that arrives before the split prevents the bug.
  • The child of X was empty, and an empty directory isn't exported for a pin.

It now gives the child an entry, clears its pin after the round trip, unmounts before flushing the journal, and drops the survivor's cache only once the recovering rank holds more than one of X's dirfrags. After the recovering rank goes active it watches the survivor in the FSMap instead of with a tell, because a tell to an MDS that is still writing its core never returns. It also runs in fs:functional now (qa/suites/fs/functional/tasks/rejoin.yaml).

A/B under vstart_runner (4 MDS, 3 active), the same build with and without 580e193:

  • Without the fix: 3 of 3 failed with rank 0 failed during R's recovery. The survivor aborted on ceph_assert(isolated_inodes.empty()) each time.
  • With the fix: 3 of 3 passed. The recovering rank logged not acking for 50 to 52 stale leaf replicas per run.

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

We hit this assert in production today on Reef 18.2.8, which already includes #56747 (the reef backport of #52648).

  • File system with 6 active ranks. Rank 2 aborted on a separate crash. A standby took the rank, went through replay, resolve and reconnect in 6 s, then stayed in up:rejoin for about 9 minutes.
  • Rank 0, an already-active survivor, aborted as rank 2 finished rejoin:
src/mds/MDCache.cc: 5136: FAILED ceph_assert(isolated_inodes.empty())
 ceph version 18.2.8 (efac5a54607c13fa50d4822e50242b86e6e446df) reef (stable)
 1: (ceph::__ceph_assert_fail(char const*, char const*, int, char const*)+0x11e)
 3: (MDCache::handle_cache_rejoin_ack(boost::intrusive_ptr<MMDSCacheRejoin const> const&)+0x21b4)
 4: (MDCache::dispatch(boost::intrusive_ptr<Message const> const&)+0x3f7)
 5: (MDSRank::_dispatch(boost::intrusive_ptr<Message const> const&, bool)+0x50b)
 6: (MDSRankDispatcher::ms_dispatch(boost::intrusive_ptr<Message const> const&)+0x5c)
 7: (MDSDaemon::ms_dispatch2(boost::intrusive_ptr<Message> const&)+0x1a0)
 8: (DispatchQueue::entry()+0x4ba)
  • Timeline (UTC): rank 2 up:rejoin 21:55:44, rank 0 abort 22:04:20, rank 2 up:clientreplay 22:04:25.
  • During that window, rank 0's RSS was about 44 GiB against a 32 GiB mds_cache_memory_limit, with about 9M inodes cached, and its inodes_expired counter rose 1.1–1.3M every 5 minutes.

debug_mds was at the default 1/5, so the log doesn't show which dirfrag was left isolated. It is the case this PR targets: an active survivor trimming during a long peer rejoin, which the deferral in #52648 doesn't cover.

@vshankar

vshankar commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

We hit this assert in production today on Reef 18.2.8, which already includes #56747 (the reef backport of #52648).

I understand. We need to include this fix in the next point-releases. I am reviewing this on prio and will put it to test if everything looks fine. Thanks for the quick turnaround on this @anthonyeleven

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor comments. Otherwise LGTM.

Comment thread src/mds/MDCache.cc Resolved
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

Comment thread qa/tasks/cephfs/test_rejoin.py Resolved
handle_cache_rejoin_ack() on a surviving (active) MDS builds an
isolated_inodes set for every acked strong dirfrag whose inode it no
longer has in cache, and then asserts that set is empty, expecting a
dentry in the same ack to reconnect each one:

  // FIXME: This can happen if entire subtree, together with the inode
  // subtree root belongs to, were trimmed between sending cache rejoin
  // and receiving rejoin ack.
  ceph_assert(isolated_inodes.empty());

A recovering rank can send exactly such an ack. When it processes a
peer's strong rejoin for a fragmented directory it does not have in
cache, rejoin_invent_dirfrag() invents a single frag_t() dirfrag and
records the peer as its replica. After the inode is fetched,
opened_undef_inode() -> CInode::force_dirfrags() splits that invented
dirfrag, and CDir::split() copies the replica map onto every leaf, so
the peer is now recorded as a replica of leaves it never held. If the
peer then trims that directory and sends a cache expire before we send
our rejoin ack, handle_cache_expire() removes the peer from the inode
and from the few leaves named in the expire, but the other leaves keep
the stale replica. rejoin_send_acks() then acks those leaves to the
peer without acking the inode (it is no longer a replica), and the peer
crashes on the isolated_inodes assert.

A dirfrag replica cannot exist without an inode replica, so acking a
dirfrag to a peer that we do not record as a replica of its inode is
never correct. In rejoin_send_acks(), for inodes we are authoritative
for, skip acking a dirfrag to such a peer and drop the stale replica.
Base inodes, and inodes we are not authoritative for (the subtree-root
case the FIXME describes), are left alone. This does not rely on
replica nonces, which are unreliable here because split() gives every
leaf the parent frag's nonce.

Subtree-root dirfrags are excluded as well. rejoin_send_acks() walks
the subtree map in pointer order, and the "peer missed MDentryLink"
fix-up adds an inode replica only while processing the parent dir's
dentries. Inside one subtree's walk that always happens before the
child dirfrags are visited, so the inode's replica map is final when
the check runs. A subtree root whose inode is auth here but lives in
another of our subtrees (export pins can keep same-auth subtrees
apart) may be visited before that fix-up, and the check could then
drop a legitimate replica. Subtree roots are known after replay from
ESubtreeMap and are never invented and split, so the stale-replica
case does not arise for them.

Fixes: https://tracker.ceph.com/issues/80407
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
The isolated_inodes crash in handle_cache_rejoin_ack() (tracker 80407)
depends on a surviving peer trimming a directory and sending a cache
expire in the short window between a recovering rank fetching an
invented, fragmented inode and that rank sending its rejoin acks. By
hand the window is too small to hit reliably.

Add a dev-only option, mds_debug_rejoin_ack_delay, that defers
rejoin_send_acks() by the configured number of seconds once the undef
dirfrags have been fetched. The delay is a timer event, not a sleep, so
the rank keeps dispatching messages and keeps processing the peer's
cache expire while it waits; this widens the race rather than masking
it. Default 0 (disabled); used by the qa reproducer.

The rank stays in rejoin_ack_gather while the event is queued, so
rejoin_gather_finish() can be called again. Keep the event and return
early while it is set: the acks go out once, when it fires, and the
gather steps aren't repeated.

Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
Add TestCacheRejoin.test_rejoin_ack_isolated_inode for tracker 80407,
and run it in fs:functional, whose cluster has the four MDS daemons it
needs.

A fragmented directory X, authoritative on rank R, is replicated on a
survivor S (inode plus one leaf frag). R is failed; the new R has no X
in cache, invents it from S's strong rejoin, and splits it once it
learns the fragtree, so S is recorded on every leaf. S then trims X and
sends a cache expire before R acks. Before the fix R acked the orphan
leaves and S crashed on ceph_assert(isolated_inodes.empty()).

R only invents X if nothing it replays or reopens names X, so the test:

- moves a child of X to S and back, then clears the pin, so S holds an
  ordinary replica and R's subtree map doesn't journal X;
- unmounts the client before flushing R's journal, since reconnected
  caps are opened from disk before rejoins are sent;
- drops S's cache only once R holds more than one of X's dirfrags: an
  expire that arrives before the split prevents the bug.

mds_debug_rejoin_ack_delay holds R's acks for 60 seconds, which makes
the window deterministic. After R goes active the test watches S in the
FSMap for a beacon timeout instead of asking it for status: an MDS
still writing its core never answers a tell.

Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
@anthonyeleven
anthonyeleven force-pushed the wip-mds-rejoin-ack-replica branch from 84fb53c to 3acd5a1 Compare November 14, 2026 11:06
test_rejoin_ack_isolated_inode passed whenever the survivor stayed up,
which it also does when the race is missed, for example when the expire
arrives before the split, so a pass didn't prove the fix. After recovery,
require the recovering rank's log to show that it dropped a stale replica
instead of acking it. Ask the daemon for its log path, since it differs
between teuthology and vstart_runner. fs:functional runs with debug mds
20, and the line is logged at 10.

Fixes: https://tracker.ceph.com/issues/80407
Signed-off-by: Anthony D'Atri <[email protected]>
Assisted-by: Claude Opus-5.5
@salieri11

Copy link
Copy Markdown
Contributor

PR is good to go when all checks are green

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test api

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test signed

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test submodules

@anthonyeleven

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@vshankar

Copy link
Copy Markdown
Contributor

jenkins test make check

@salieri11 salieri11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for working on this one!

@xiubli xiubli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch. LGTM.

I have run the tests/regressions and no issue found.

@vshankar

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by vshankar started 2026-11-24-04:06.

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vshankar
vshankar merged commit 46c97f2 into ceph:main Nov 26, 2026
21 checks passed
@anthonyeleven

Copy link
Copy Markdown
Contributor Author

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.

4 participants