Repository navigation
mds/osdc: avoid Objecter balanced-budget deadlocks under metadata load - #71959
edwinzrodriguez wants to merge 5 commits into
Conversation
Under metadata load the MDS submit thread can block in Objecter::_throttle_op while holding Journaler::lock (filer.zero / filer.write / write_head from append/flush/prezero). Objecter correctly drops its own lock before waiting on the throttle, but Journaler did not. The SafeTimer thread then runs scatter_tick under mds_lock, calls MDLog::submit_entry -> get_layout_period (or flush), and blocks forever on Journaler::lock. Every client path that needs mds_lock stalls; the rank goes laggy and admin socket stops responding. Fix this the same way write_buf_throttle already does: drop Journaler::lock around Objecter submits that can throttle, after updating journal pointers under the lock. Also cache layout.period() in an atomic so get_layout_period() is lock-free after set_layout — that is the exact wait site seen in the stall backtrace. Add unittest_journaler_lock to regress the get_layout_period path: one thread holds Journaler::lock while another calls get_layout_period; the call must complete (Journaler::lock is non-recursive, so taking it again would hang). Fixes: https://tracker.ceph.com/issues/80667 Co-authored-by: Cursor <[email protected]> Signed-off-by: Edwin Rodriguez <[email protected]>
After the Journaler unlock-across-throttle fix, the MDS can still go laggy under metadata load: MDLog::log_trim_upkeep holds mds_lock through trim -> try_to_expire -> MDSTable::save / SessionMap::save (and open-file table commit). Those paths call Objecter::write_full/mutate, which may block in _throttle_op. While throttled with mds_lock held, dispatch, asok, and beacon heartbeat cannot run; the rank reports slow requests and "MDS internal heartbeat is not healthy". Drop mds_lock around the Objecter submits in MDSTable::save, SessionMap::save / save_if_dirty, and OpenFileTable::commit. Defer a new table/sessionmap write while one is already in flight, and kick a follow-up save when the in-flight write completes if the version advanced while the lock was dropped. Add unittest_mds_table_save_unlock to regress the unlock window (another thread must be able to take mds_lock while save is in submit) and the defer-overlapping-save behavior. Fixes: https://tracker.ceph.com/issues/80667 Signed-off-by: Edwin Rodriguez <[email protected]>
After unlocking the Journaler and log-trim table/sessionmap paths across Objecter::_throttle_op, the active MDS can still go laggy under metadata load. Client request dispatch holds mds_lock through Server -> MDCache::path_traverse -> CDir::fetch -> CDir::_omap_fetch, which calls Objecter::read. When the Objecter op budget is exhausted, _throttle_op blocks while mds_lock is still held, so heartbeat cannot be reset, beacons are skipped, and the rank is failed over. The same pattern appears on successor actives (openc/getattr dir fetch) and on locked CInode store/fetch/backtrace submits. GDB on stalled nodes showed ms_dispatch waiting in Throttle::_wait under CDir::_omap_fetch, with mds-log-trim and other threads blocked on fair_mutex for mds_lock. Drop mds_lock around the Objecter submit in CDir::_omap_fetch and _omap_fetch_more (dirfrag remains auth-pinned for the unlock window), and likewise in CInode::store, CInode::fetch, and CInode::_commit_ops when the caller holds mds_lock. _commit_ops still runs unlocked on the finisher BatchCommitBacktrace path. Fixes: https://tracker.ceph.com/issues/80667 Signed-off-by: Edwin Rodriguez <[email protected]>
After set_balanced_budget() (tracker ceph#71136), Objecter::_throttle_op can block the calling thread until inflight OSD ops complete and free budget. OSD replies that release that budget are handled on ms_dispatch. When ms_dispatch (or the MDS completion finisher) itself blocks in the throttle — e.g. CDir::_omap_fetch during path_traverse, or _omap_commit_ops on mds-rank-fin — replies never run, the throttle never puts, and the MDS wedges (client creates stuck at journal_and_reply). Dropping mds_lock across Objecter submit is not enough: the dispatch thread must not wait on the same throttle that only it can advance. Keep balanced-budget throttling, but move Objecter submits that may block onto a dedicated objecter_finisher (mds-obj-fin) via queue_objecter(). ms_dispatch and the completion finisher stay free to process replies. Route dir/inode fetch and commit, backtrace batch commits, OpenFileTable, SessionMap, and MDSTable Objecter I/O through that path. Fixes: https://tracker.ceph.com/issues/80667 Signed-off-by: Edwin Rodriguez <[email protected]>
ff2af3b to
b5bc8dd
Compare
#66578 isn't backported to any point release branches. |
|
jenkins test make check |
|
The root cause is not fully addressed; I reproduced a permanent hang with this PR applied. OSD op replies are fast-dispatched and do not need
So the resend never happens because the new osdmap is stuck behind |
After set_balanced_budget(), Objecter::_throttle_op can block until OSD replies free budget. Those replies are delivered on ms_dispatch, which must take mds_lock first. PurgeQueue's SafeTimer shares PurgeQueue::lock with safe_callbacks=true, so the delayed journaler.flush() callback held that lock while blocked in the Objecter throttle. MDCache trim holds mds_lock across PurgeQueue::push(), so it stalled acquiring PurgeQueue::lock; ms_dispatch then stalled on mds_lock and replies never ran — permanent deadlock. The same pattern existed for append_entry in push() and write_head under the lock. Construct the PurgeQueue timer with safe_callbacks=false, drop PurgeQueue::lock around Journaler append/flush/write_head, and only clear delayed_flush when the firing context is still current. Fixes: https://tracker.ceph.com/issues/80667 Signed-off-by: Edwin Rodriguez <[email protected]>
b5bc8dd to
37c177c
Compare
|
I've been wondering myself if set_balanced_budget() is worth the cost. I'm not even sure it will help, more likely hurt without a protocol change to add some kind of flow control to mds traffic from the client. What will probably happen is we'll get a massive backlog in the mds that will stall it until it eventually starts dropping heartbeats and fails over. Where the process begins again. |
|
set_balanced_budget() was added for #71136 to bound unbounded Objecter queueing / MDS OOMs.Need to decide if we want keep some bound, but a blocking wait on the MDS dispatch/finisher threads is the wrong solution given how maps and replies interact. Other options:
|
|
jenkins make check arm64 |
vshankar
left a comment
There was a problem hiding this comment.
It seems to me that there are still cases where things can lockup and/or misbehave due to the lock being dropped before calling into objecter/filer.
nit: use Assisted-by: <LLM> in place of Co-authored-by: in the commit message. That's the norm ceph is being follwowing.
| uint32_t iohint = write_iohint; | ||
|
|
||
| // Objecter may block in _throttle_op; do not hold Journaler::lock across that. | ||
| l.unlock(); |
There was a problem hiding this comment.
This is probably already handled correctly, but, _write_head() drops Journaler::lock before write_full(). A second header write can start while the first is blocked in Objecter::_throttle_op (via flush()). _finish_write_head() aborts if the older header completes after last_committed has moved forward. Has this overlap been checked?
| ceph_assert(write_pos > requested_pos); | ||
| if (pending_safe.empty()) { | ||
| _flush(NULL); | ||
| _flush(l, NULL); |
There was a problem hiding this comment.
There might be an issue here: _issue_read() queues C_RetryRead only after _flush() returns. _flush() submits filer.write() and then drops Journaler::lock again before that queue. If _finish_flush() runs in any of those unlocked sections, it advances safe_pos while waitfor_safe does not yet contain C_RetryRead. The waiter is then inserted at next_safe_pos, which is already safe, and nothing completes it unless a later flush moves safe_pos. Has this been checked?
| l.lock(); | ||
| } | ||
|
|
||
| void Journaler::_finish_write_head(int r, Header &wrote, |
There was a problem hiding this comment.
This also calls _trim() which would call filer.purge_range(...) with lock held.
I kind of agree. Fixes like these should bake in the branch before making it to a release. Maybe revert #66578 for now?
Just FYI - Such a feature is desirable and also prevents us from bloating the MDS journal when log trimming is slow/stuck. See discussion: #71802 (comment) |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
Summary
Objecter::set_balanced_budget()(tracker mds: enable osdc op throttles #66578),_throttle_opcan block the caller until OSD replies free budget. Those replies are delivered onms_dispatch, which must takemds_lockfirst. Holdingmds_lock(or another mutex thatms_dispatch/trim depends on) across a throttled Objecter submit wedges the MDS under SpecStorage2020-class metadata load.Journaler::lockaround Objecter submits that can throttle; makeget_layout_period()lock-free afterset_layout.mds_lockaround Objecter submits on the log-trim table/sessionmap/OFT path and on dir/inode fetch/store/backtrace; defer overlapping table/sessionmap saves.ms_dispatch/mds-rank-finonto a dedicatedobjecter_finisher(mds-obj-fin) viaqueue_objecter(). Also deferMDLog::flush/write_headso they never block undermds_lock.SafeTimersharesPurgeQueue::lockwithsafe_callbacks=true, so delayedjournaler.flush()held that lock across the Objecter throttle while cache trim heldmds_lockinpush()— permanent deadlock. Usesafe_callbacks=falseand drop the lock around Journaler append/flush/write_head.Commits
osdc/Journaler: do not hold lock across Objecter throttle(Fixes: https://tracker.ceph.com/issues/80667)mds: do not hold mds_lock across Objecter throttle on trim pathmds: do not hold mds_lock across Objecter throttle on dir/inode I/Omds: submit Objecter ops on dedicated finisher under balanced budgetmds: do not hold PurgeQueue lock across Objecter throttleTest plan
unittest_journaler_lock—get_layout_period()does not takeJournaler::lockunittest_mds_table_save_unlock— unlock window + defer overlappingMDSTable::savebin/ceph-mdswith the series appliedmds_cache_memory_limitstressed; confirm noms_dispatch/ asok / beacon wedge from Objecter throttle × lock cyclesgdbbacktraces: no thread should holdmds_lockorPurgeQueue::lockwhile blocked inObjecter::_throttle_op/Throttle::_waitSigned-off-by: Edwin Rodriguez [email protected]
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.