Bug #80667
openMDS stalls when Journaler holds lock across Objecter throttle (scatter_tick / get_layout_period)
0%
Description
Summary¶
Under heavy metadata load, ceph-mds can become fully unresponsive (active(laggy), admin socket timeouts, clients blocked on creates/getattrs) because the MDLog submit thread holds Journaler::lock while blocked in Objecter::_throttle_op, and the SafeTimer thread then waits forever on that same lock while already holding mds_lock.
Observed symptoms¶
- MDS rank stuck
active(laggy)with large cache / many caps ceph daemon … dump_blocked_ops/ admin socket: timeout orEAGAIN/ "Resource temporarily unavailable"- Clients show outstanding mdsc requests (create/getattr) with no MDS progress
- GDB backtrace pattern (umbrella-release):
- mds-log-submit:
Throttle::get→Objecter::_throttle_op→Filer::zero→Journaler::_issue_prezero→_do_flush→append_entry(holdsJournaler::lock) - SafeTimer / tick:
Journaler::get_layout_period→MDLog::_segment_upkeep→MDLog::submit_entry→Locker::scatter_writebehind→scatter_tick(holdsmds_lock, waiting onJournaler::lock)
- mds-log-submit:
Root cause¶
Objecter::_throttle_op correctly drops the Objecter lock before waiting on op_throttle_ops / op_throttle_bytes.
Journaler did not drop Journaler::lock around Objecter submits that can throttle (filer.zero / filer.write / write_full from prezero/flush/write_head).
Meanwhile Locker::scatter_tick runs under mds_lock and MDLog::submit_entry → _segment_upkeep calls journaler->get_layout_period(), which took Journaler::lock. That wait never completes while submit is throttled, so mds_lock is held indefinitely and the MDS stalls.
Reproducer notes¶
- Metadata-heavy workload (e.g. SFS2020 SWBUILD) with enough concurrent journal / OSD traffic to hit
objecter_inflight_ops/objecter_inflight_op_bytes - Lowering those limits makes the race easier to hit
- Unit regression:
unittest_journaler_lock(holdJournaler::lockin one thread;get_layout_period()from another must not block)
Proposed fix¶
- Drop
Journaler::lockaround Objecter submits that can throttle (same pattern as existingwrite_buf_throttleunlock-before-wait), after updating journal pointers under the lock. - Cache
layout.period()in an atomic soget_layout_period()is lock-free afterset_layout— avoids the exact wait site in the stall stack.
Affected component / versions¶
- Component:
osdc/ CephFS MDS (Journaler,MDLog, scatter writebehind) - Seen on umbrella-release / recent mainline MDS builds under kernel CephFS metadata load
ER Updated by Edwin Rodriguez 2 months ago
The change that introduced the problem is e5abac30b2e (mds: enable osdc op throttles, merged as PR https://github.com/ceph/ceph/pull/66578 / 15d87f6c9cf), tracker https://tracker.ceph.com/issues/71136
It adds a single call in MDSRank:
objecter->set_balanced_budget();
That flips Objecter’s keep_balanced_budget path so _take_op_budget uses blocking _throttle_op (drop Objecter rwlock → Throttle::get) instead of the non-blocking take() accounting MDS had always used.
Holding Journaler::lock / mds_lock across Objecter submit was already common (trim path, table saves, CDir::_omap_fetch, etc.). That was harmless until this commit made Objecter able to block under those locks.
src/osdc itself did not newly introduce the MDS hang on this branch: the throttle machinery (keep_balanced_budget / _throttle_op) has been there for a long time; MDS simply never opted in until #66578.
Related but not on this tree: the ceph-bench-tentacle-osdc Objecter ASIO-strand series (405e85dc50a … 0647c0af19c) can amplify the same class of stall if OSD replies share the asio pool with submitters.
PD Updated by Patrick Donnelly 2 months ago
Meanwhile Locker::scatter_tick runs under mds_lock and MDLog::submit_entry → _segment_upkeep calls journaler->get_layout_period(), which took Journaler::lock. That wait never completes while submit is throttled, so mds_lock is held indefinitely and the MDS stalls.
If we can avoid acquiring the journaler lock (and there are no other relevant paths), that would probably be the best solution here. `get_layout_period` certainly does not need a lock as the layout never changes once set on journal creation.
ER Updated by Edwin Rodriguez 2 months ago
I made get_layout_period an atomic so it can be accessed without requiring a lock. The bigger issue is that there are a lot of paths that end up in objecter.
the MDS submit thread blocks in Objecter::_throttle_op while holding Journaler::lock
Thread 17 (Thread 0x7fffef9776c0 (LWP 458160) "safe_timer"):
#0 0x00007ffff60b99d0 in __lll_lock_wait () from /lib64/libc.so.6
#1 0x00007ffff60bfdf2 in pthread_mutex_lock@@GLIBC_2.2.5 () from /lib64/libc.so.6
#2 0x0000555555aea354 in __gthread_mutex_lock (__mutex=0x55555776a988) at /usr/include/c++/14/x86_64-redhat-linux/bits/gthr-default.h:762
#3 std::mutex::lock (this=0x55555776a988) at /usr/include/c++/14/bits/std_mutex.h:113
#4 std::lock_guard<std::mutex>::lock_guard (this=<synthetic pointer>, __m=...) at /usr/include/c++/14/bits/std_mutex.h:250
#5 Journaler::get_layout_period (this=0x55555776a900) at /root/git/umbrella-release/src/osdc/Journaler.h:526
#6 MDLog::_segment_upkeep (this=0x55555762a400) at /root/git/umbrella-release/src/mds/MDLog.cc:447
#7 0x00005555559741c6 in MDLog::submit_entry (this=0x55555762a400, e=0x5559a21d3400, c=0x55599ba067c0) at /root/git/umbrella-release/src/mds/MDLog.h:151
#8 0x00005555559895d2 in Locker::scatter_writebehind (this=0x5555565e6a00, lock=0x5555f1456fd0) at /root/git/umbrella-release/src/mds/Locker.cc:5273
#9 0x000055555598f3b7 in Locker::scatter_nudge (this=this@entry=0x5555565e6a00, lock=lock@entry=0x5555f1456fd0, c=c@entry=0x0, forcelockchange=forcelockchange@entry=false) at /root/git/umbrella-release/src/mds/Locker.cc:5448
#10 0x00005555559901ba in Locker::scatter_tick (this=0x5555565e6a00) at /root/git/umbrella-release/src/mds/Locker.cc:5522
#11 0x0000555555990549 in Locker::tick (this=0x5555565e6a00) at /root/git/umbrella-release/src/mds/Locker.cc:121
#12 0x000055555574a3a2 in MDSRankDispatcher::tick (this=0x555557671400) at /root/git/umbrella-release/src/mds/MDSRank.cc:732
#13 0x000055555572bb09 in Context::complete (this=0x5557bf029460, r=<optimized out>) at /root/git/umbrella-release/src/include/Context.h:107
#14 0x00007ffff7070316 in CommonSafeTimer<ceph::fair_mutex>::timer_thread (this=0x5555573c0078) at /root/git/umbrella-release/src/common/Timer.cc:117
#15 0x00007ffff707138d in CommonSafeTimerThread<ceph::fair_mutex>::entry (this=<optimized out>) at /root/git/umbrella-release/src/common/Timer.cc:34
#16 0x00007ffff60bc8bf in start_thread () from /lib64/libc.so.6
#17 0x00007ffff612d43c in clone3 () from /lib64/libc.so.6
Thread 7 (Thread 0x7fffea96d6c0 (LWP 1244090) "mds-rank-fin"):
#0 0x00007ffff60b977e in __futex_abstimed_wait_common () from /lib64/libc.so.6
#1 0x00007ffff60bbe58 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libc.so.6
#2 0x00007ffff62e3d60 in __gthread_cond_wait (__cond=0x5559a014aed0, __mutex=<optimized out>) at /usr/src/debug/gcc-14.3.1-4.4.el10.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/x86_64-redhat-linux/bits/gthr-default.h:878
#3 std::__condvar::wait (this=0x5559a014aed0, __m=...) at /usr/src/debug/gcc-14.3.1-4.4.el10.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/std_mutex.h:171
#4 std::condition_variable::wait (this=this@entry=0x5559a014aed0, __lock=...) at ../../../../../libstdc++-v3/src/c++11/condition_variable.cc:41
#5 0x00007ffff706b6d5 in std::condition_variable::wait<Throttle::_wait(int64_t, std::unique_lock<std::mutex>&)::<lambda()> > (this=<optimized out>, __lock=..., __p=...) at /usr/include/c++/14/condition_variable:105
#6 Throttle::_wait (this=this@entry=0x5555565dab30, c=c@entry=1, l=...) at /root/git/umbrella-release/src/common/Throttle.cc:109
#7 0x00007ffff706bd47 in Throttle::get (this=this@entry=0x5555565dab30, c=c@entry=1, m=m@entry=0) at /root/git/umbrella-release/src/common/Throttle.cc:173
#8 0x00007ffff7622e47 in Objecter::_throttle_op (this=this@entry=0x5555565da600, op=op@entry=0x5559a4e1c300, sul=..., op_budget=op_budget@entry=213) at /root/git/umbrella-release/src/osdc/Objecter.cc:3707
#9 0x00007ffff76407b6 in Objecter::_take_op_budget (this=0x5555565da600, op=0x5559a4e1c300, sul=...) at /root/git/umbrella-release/src/osdc/Objecter.h:2692
#10 Objecter::_op_submit_with_budget (this=0x5555565da600, op=0x5559a4e1c300, sul=..., ptid=0x7fffea96a3d0, ctx_budget=0x0) at /root/git/umbrella-release/src/osdc/Objecter.cc:2447
#11 0x00007ffff7640929 in Objecter::op_submit (this=this@entry=0x5555565da600, op=op@entry=0x5559a4e1c300, ptid=ptid@entry=0x7fffea96a3d0, ctx_budget=ctx_budget@entry=0x0) at /root/git/umbrella-release/src/osdc/Objecter.cc:2420
#12 0x0000555555a624ad in Objecter::mutate (reqid=..., this=0x5555565da600, oid=..., oloc=..., op=..., snapc=..., mtime=..., flags=0, oncommit=<optimized out>, objver=0x0) at /root/git/umbrella-release/src/osdc/Objecter.h:3106
#13 CInode::_commit_ops (this=0x55596a6ccc00, r=<optimized out>, gather_bld=..., ops_vec=..., bt=...) at /root/git/umbrella-release/src/mds/CInode.cc:1461
#14 0x00005555557c9b19 in BatchCommitBacktrace::finish (this=0x555978af89f0, r=0) at /root/git/umbrella-release/src/mds/journal.cc:113
#15 0x000055555572bb09 in Context::complete (this=0x555978af89f0, r=<optimized out>) at /root/git/umbrella-release/src/include/Context.h:107
#16 0x00007ffff7026a7e in Finisher::finisher_thread_entry (this=0x5555566e26e0) at /root/git/umbrella-release/src/common/Finisher.cc:113
#17 0x00007ffff60bc8bf in start_thread () from /lib64/libc.so.6
#18 0x00007ffff612d43c in clone3 () from /lib64/libc.so.6
Thread 6 (Thread 0x7fffe996b6c0 (LWP 1244092) "mds-log-submit"):
#0 0x00007ffff60b977e in __futex_abstimed_wait_common () from /lib64/libc.so.6
#1 0x00007ffff60bbe58 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libc.so.6
#2 0x00007ffff62e3d60 in __gthread_cond_wait (__cond=0x555764800450, __mutex=<optimized out>) at /usr/src/debug/gcc-14.3.1-4.4.el10.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/x86_64-redhat-linux/bits/gthr-default.h:878
#3 std::__condvar::wait (this=0x555764800450, __m=...) at /usr/src/debug/gcc-14.3.1-4.4.el10.x86_64/obj-x86_64-redhat-linux/x86_64-redhat-linux/libstdc++-v3/include/bits/std_mutex.h:171
#4 std::condition_variable::wait (this=this@entry=0x555764800450, __lock=...) at ../../../../../libstdc++-v3/src/c++11/condition_variable.cc:41
#5 0x00007ffff706b6d5 in std::condition_variable::wait<Throttle::_wait(int64_t, std::unique_lock<std::mutex>&)::<lambda()> > (this=<optimized out>, __lock=..., __p=...) at /usr/include/c++/14/condition_variable:105
#6 Throttle::_wait (this=this@entry=0x5555565dab30, c=c@entry=1, l=...) at /root/git/umbrella-release/src/common/Throttle.cc:109
#7 0x00007ffff706bd47 in Throttle::get (this=this@entry=0x5555565dab30, c=c@entry=1, m=m@entry=0) at /root/git/umbrella-release/src/common/Throttle.cc:173
#8 0x00007ffff7622e47 in Objecter::_throttle_op (this=this@entry=0x5555565da600, op=op@entry=0x55599a3fb700, sul=..., op_budget=op_budget@entry=0) at /root/git/umbrella-release/src/osdc/Objecter.cc:3707
#9 0x00007ffff76407b6 in Objecter::_take_op_budget (this=0x5555565da600, op=0x55599a3fb700, sul=...) at /root/git/umbrella-release/src/osdc/Objecter.h:2692
#10 Objecter::_op_submit_with_budget (this=0x5555565da600, op=0x55599a3fb700, sul=..., ptid=0x7fffe99681d8, ctx_budget=0x0) at /root/git/umbrella-release/src/osdc/Objecter.cc:2447
#11 0x00007ffff7640929 in Objecter::op_submit (this=this@entry=0x5555565da600, op=op@entry=0x55599a3fb700, ptid=ptid@entry=0x7fffe99681d8, ctx_budget=ctx_budget@entry=0x0) at /root/git/umbrella-release/src/osdc/Objecter.cc:2420
#12 0x0000555555bb1285 in Objecter::remove (this=0x5555565da600, oid=..., oloc=..., snapc=..., mtime=..., mtime@entry=ceph::real_clock time_point = { 1789776454414392112ns }, flags=flags@entry=0, oncommit=0x555994495b40, objver=0x0, extra_ops=0x0) at /root/git/umbrella-release/src/osdc/Objecter.h:3784
#13 0x0000555555bb8a16 in Filer::zero (this=this@entry=0x55555776aac0, ino=..., layout=layout@entry=0x55555776aa70, snapc=..., offset=248168579072, len=len@entry=4194304, mtime=..., flags=0, keep_first=false, oncommit=0x555994495b40) at /root/git/umbrella-release/src/osdc/Filer.cc:131
#14 0x0000555555b635af in Filer::zero (this=0x55555776aac0, ino=..., layout=0x55555776aa70, snapc=..., offset=<optimized out>, len=4194304, mtime=..., flags=0, oncommit=0x555994495b40) at /root/git/umbrella-release/src/osdc/Filer.h:196
#15 Journaler::_issue_prezero (this=this@entry=0x55555776a900) at /root/git/umbrella-release/src/osdc/Journaler.cc:863
#16 0x0000555555b63e48 in Journaler::_do_flush (this=this@entry=0x55555776a900, amount=<optimized out>) at /root/git/umbrella-release/src/osdc/Journaler.cc:674
#17 0x0000555555b64634 in Journaler::append_entry (this=0x55555776a900, bl=...) at /root/git/umbrella-release/src/include/buffer.h:1028
#18 0x0000555555aecd9c in MDLog::_submit_thread (this=0x55555762a400) at /root/git/umbrella-release/src/mds/MDLog.cc:543
#19 0x0000555555af777d in MDLog::SubmitThread::entry (this=<optimized out>) at /root/git/umbrella-release/src/mds/MDLog.h:229
#20 0x00007ffff60bc8bf in start_thread () from /lib64/libc.so.6
#21 0x00007ffff612d43c in clone3 () from /lib64/libc.so.6
VS Updated by Venky Shankar 2 months ago
- Related to Bug #71136: scrub uses unbounded memory and OOM when repairing the inotable added
VS Updated by Venky Shankar 2 months ago
- Category set to Correctness/Safety
- Target version set to v22.0.0
- Source set to Development
- Severity changed from 3 - minor to 2 - major
- Component(FS) MDS, osdc added