Project

General

Profile

Actions

Bug #71303

closed
NM NM

ceph-mon shutdown hang

Bug #71303: ceph-mon shutdown hang

Added by Nitzan Mordechai over 1 year ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Normal
Category:
-
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
squid, tentacle
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(RADOS):
Pull request ID:
Tags (freeform):
Fixed In:
v20.3.0-1782-gf287d661ba
Released In:
v21.2.0~2443
Upkeep Timestamp:
2026-10-24T01:57:19+00:00

Description

During a test of rados/valgrind-leaks we are completing the test and trying to shut down the cluster. We can see the following shutdown process:

2025-04-23T21:16:23.999 INFO:tasks.ceph.osd.0:Stopped
2025-04-23T21:16:23.999 DEBUG:tasks.ceph.osd.1:waiting for process to exit
2025-04-23T21:16:23.999 INFO:teuthology.orchestra.run:waiting for 300
2025-04-23T21:16:24.014 INFO:tasks.ceph.osd.1.smithi063.stderr:2025-04-23T21:16:24.001+0000 add4640 -1 received  signal: Terminated from /usr/bin/python3 /bin/daemon-helper term env OPENSSL_ia32cap=~0x1000000000000000 valgrind --trace-children=no --child-silent-after-fork=yes --soname-synonyms=somalloc=*tcmalloc* --num-callers=50 --suppressions=/home/ubuntu/cephtest/valgrind.supp --gen-suppressions=all --xml=yes --xml-file=/var/log/ceph/valgrind/osd.1.log --time-stamp=yes --vgdb=yes --exit-on-first-error=yes --error-exitcode=42 --tool=memcheck ceph-osd -f --cluster ceph -i 1  (PID: 37122) UID: 0
2025-04-23T21:16:24.014 INFO:tasks.ceph.osd.1.smithi063.stderr:2025-04-23T21:16:24.003+0000 add4640 -1 osd.1 17 *** Got signal Terminated ***
2025-04-23T21:16:30.101 INFO:tasks.ceph.osd.1:Stopped
2025-04-23T21:16:30.101 DEBUG:tasks.ceph.osd.2:waiting for process to exit
2025-04-23T21:16:30.101 INFO:teuthology.orchestra.run:waiting for 300
2025-04-23T21:16:30.116 INFO:tasks.ceph.osd.2.smithi063.stderr:2025-04-23T21:16:30.104+0000 add4640 -1 received  signal: Terminated from /usr/bin/python3 /bin/daemon-helper term env OPENSSL_ia32cap=~0x1000000000000000 valgrind --trace-children=no --child-silent-after-fork=yes --soname-synonyms=somalloc=*tcmalloc* --num-callers=50 --suppressions=/home/ubuntu/cephtest/valgrind.supp --gen-suppressions=all --xml=yes --xml-file=/var/log/ceph/valgrind/osd.2.log --time-stamp=yes --vgdb=yes --exit-on-first-error=yes --error-exitcode=42 --tool=memcheck ceph-osd -f --cluster ceph -i 2  (PID: 37123) UID: 0
2025-04-23T21:16:30.116 INFO:tasks.ceph.osd.2.smithi063.stderr:2025-04-23T21:16:30.105+0000 add4640 -1 osd.2 19 *** Got signal Terminated ***
2025-04-23T21:16:30.452 INFO:tasks.daemonwatchdog.daemon_watchdog:daemon ceph.osd.1 is failed for ~0s
2025-04-23T21:16:36.056 INFO:tasks.daemonwatchdog.daemon_watchdog:daemon ceph.osd.1 has been restored
2025-04-23T21:18:44.329 INFO:tasks.ceph.osd.2:Stopped
2025-04-23T21:18:44.330 INFO:teuthology.misc:Shutting down mgr daemons...
2025-04-23T21:18:44.330 DEBUG:tasks.ceph.mgr.x:waiting for process to exit
2025-04-23T21:18:44.330 INFO:teuthology.orchestra.run:waiting for 300
2025-04-23T21:18:44.359 INFO:tasks.ceph.mgr.x:Stopped
2025-04-23T21:18:44.359 DEBUG:tasks.ceph.mgr.y:waiting for process to exit
2025-04-23T21:18:44.359 INFO:teuthology.orchestra.run:waiting for 300
2025-04-23T21:18:44.401 INFO:tasks.ceph.mgr.y.smithi063.stderr:2025-04-23T21:18:44.399+0000 7f0990927640 -1 received  signal: Terminated from /usr/bin/python3 /bin/daemon-helper term ceph-mgr -f --cluster ceph -i y  (PID: 36656) UID: 0
2025-04-23T21:18:44.401 INFO:tasks.ceph.mgr.y.smithi063.stderr:2025-04-23T21:18:44.399+0000 7f0990927640 -1 mgr handle_mgr_signal  *** Got signal Terminated ***
2025-04-23T21:18:44.431 INFO:tasks.ceph.mgr.y:Stopped
2025-04-23T21:18:44.431 INFO:teuthology.misc:Shutting down mon daemons...
2025-04-23T21:18:44.431 DEBUG:tasks.ceph.mon.a:waiting for process to exit
2025-04-23T21:18:44.431 INFO:teuthology.orchestra.run:waiting for 300
2025-04-23T21:18:44.489 INFO:tasks.ceph.mon.a.smithi063.stderr:2025-04-23T21:18:44.475+0000 a0b3640 -1 received  signal: Terminated from /usr/bin/python3 /bin/daemon-helper term env OPENSSL_ia32cap=~0x1000000000000000 valgrind --trace-children=no --child-silent-after-fork=yes --soname-synonyms=somalloc=*tcmalloc* --num-callers=50 --suppressions=/home/ubuntu/cephtest/valgrind.supp --gen-suppressions=all --xml=yes --xml-file=/var/log/ceph/valgrind/mon.a.log --time-stamp=yes --vgdb=yes --exit-on-first-error=yes --error-exitcode=42 --tool=memcheck --leak-check=full --show-reachable=yes ceph-mon -f --cluster ceph -i a  (PID: 36641) UID: 0
2025-04-23T21:18:44.490 INFO:tasks.ceph.mon.a.smithi063.stderr:2025-04-23T21:18:44.476+0000 a0b3640 -1 mon.a@0(leader) e1 *** Got Signal Terminated ***
2025-04-23T21:18:49.850 INFO:tasks.daemonwatchdog.daemon_watchdog:daemon ceph.mon.a is failed for ~0s
2025-04-23T21:18:50.533 INFO:tasks.ceph.mon.a:Stopped
2025-04-23T21:18:50.534 DEBUG:tasks.ceph.mon.b:waiting for process to exit
2025-04-23T21:18:50.534 INFO:teuthology.orchestra.run:waiting for 300
2025-04-23T21:18:50.551 INFO:tasks.ceph.mon.b.smithi063.stderr:2025-04-23T21:18:50.537+0000 a0b3640 -1 received  signal: Terminated from /usr/bin/python3 /bin/daemon-helper term env OPENSSL_ia32cap=~0x1000000000000000 valgrind --trace-children=no --child-silent-after-fork=yes --soname-synonyms=somalloc=*tcmalloc* --num-callers=50 --suppressions=/home/ubuntu/cephtest/valgrind.supp --gen-suppressions=all --xml=yes --xml-file=/var/log/ceph/valgrind/mon.b.log --time-stamp=yes --vgdb=yes --exit-on-first-error=yes --error-exitcode=42 --tool=memcheck --leak-check=full --show-reachable=yes ceph-mon -f --cluster ceph -i b  (PID: 36647) UID: 0
2025-04-23T21:18:50.551 INFO:tasks.ceph.mon.b.smithi063.stderr:2025-04-23T21:18:50.539+0000 a0b3640 -1 mon.b@1(peon) e1 *** Got Signal Terminated ***
2025-04-23T21:18:54.951 INFO:tasks.daemonwatchdog.daemon_watchdog:daemon ceph.mon.b is failed for ~0s
2025-04-23T21:18:54.952 INFO:tasks.daemonwatchdog.daemon_watchdog:daemon ceph.mon.a has been restored
2025-04-23T21:18:56.635 INFO:tasks.ceph.mon.b:Stopped
2025-04-23T21:18:56.635 DEBUG:tasks.ceph.mon.c:waiting for process to exit
2025-04-23T21:18:56.636 INFO:teuthology.orchestra.run:waiting for 300
2025-04-23T21:18:56.653 INFO:tasks.ceph.mon.c.smithi063.stderr:2025-04-23T21:18:56.639+0000 a0b3640 -1 received  signal: Terminated from /usr/bin/python3 /bin/daemon-helper term env OPENSSL_ia32cap=~0x1000000000000000 valgrind --trace-children=no --child-silent-after-fork=yes --soname-synonyms=somalloc=*tcmalloc* --num-callers=50 --suppressions=/home/ubuntu/cephtest/valgrind.supp --gen-suppressions=all --xml=yes --xml-file=/var/log/ceph/valgrind/mon.c.log --time-stamp=yes --vgdb=yes --exit-on-first-error=yes --error-exitcode=42 --tool=memcheck --leak-check=full --show-reachable=yes ceph-mon -f --cluster ceph -i c  (PID: 36650) UID: 0
2025-04-23T21:18:56.653 INFO:tasks.ceph.mon.c.smithi063.stderr:2025-04-23T21:18:56.640+0000 a0b3640 -1 mon.c@2(probing) e1 *** Got Signal Terminated ***
2025-04-23T21:19:00.053 INFO:tasks.daemonwatchdog.daemon_watchdog:daemon ceph.mon.b has been restored
2025-04-23T21:23:55.696 INFO:tasks.ceph:Checking cluster log for badness...
2025-04-23T21:23:55.697 DEBUG:teuthology.orchestra.run.smithi063:> sudo egrep '\[ERR\]|\[WRN\]|\[SEC\]' /var/log/ceph/ceph.log | egrep -v '\(MDS_ALL_DOWN\)' | egrep -v '\(MDS_UP_LESS_THAN_MAX\)' | egrep -v 'overall HEALTH_' | egrep -v '\(PG_' | egrep -v '\(POOL_APP_NOT_ENABLED\)' | egrep -v 'OSD bench result' | head -n 1

As you can see mon.c didn't shut down completely.


Related issues 3 (0 open — 3 closed)

Related to RADOS - Bug #63501: ceph::common::leak_some_memory() got interpreted as an actual leakBackportingNitzan Mordechai

Actions
Copied to RADOS - Backport #72212: squid: ceph-mon shutdown hang ResolvedNitzan Mordechai

Actions
Copied to RADOS - Backport #72213: tentacle: ceph-mon shutdown hang ResolvedNitzan Mordechai

Actions

NM Updated by Nitzan Mordechai over 1 year ago Actions #1

  • Related to Bug #63501: ceph::common::leak_some_memory() got interpreted as an actual leak added

NM Updated by Nitzan Mordechai over 1 year ago Actions #2

/a/yuriw-2025-04-23_17:31:54-rados-wip-yuri8-testing-2025-04-23-0802-reef-distro-default-smithi/8256202

NM Updated by Nitzan Mordechai over 1 year ago Actions #3

i ran the same tests with debug_ms = 30 ( /a/nmordech-2025-05-12_04:52:01-rados:valgrind-leaks-main-distro-default-smithi/8280966)

normal shutdown logs:

2025-05-12T05:45:24.126+0000 6960340 10 -- 172.21.15.76:0/888169474 wait: dispatch queue is stopped
2025-05-12T05:45:24.126+0000 6960340  1 -- 172.21.15.76:0/888169474 shutdown_connections 
2025-05-12T05:45:24.126+0000 6960340  5 -- 172.21.15.76:0/888169474 shutdown_connections delete 0xb4d17c0
2025-05-12T05:45:24.126+0000 6960340  5 -- 172.21.15.76:0/888169474 shutdown_connections perf_counter 0xb433320
2025-05-12T05:45:24.126+0000 6960340  5 -- 172.21.15.76:0/888169474 shutdown_connections deleted_conns size 1
2025-05-12T05:45:24.126+0000 6960340  5 -- 172.21.15.76:0/888169474 shutdown_connections deleted_conns size 0
2025-05-12T05:45:24.126+0000 6960340  5 -- 172.21.15.76:0/888169474 shutdown_connections finished
2025-05-12T05:45:24.126+0000 6960340 10 -- 172.21.15.76:0/888169474 wait: connections closed
2025-05-12T05:45:24.126+0000 6960340 20 stack drain started.
2025-05-12T05:45:24.126+0000 6960340 20 stack drain cur thread id: 110494528
2025-05-12T05:45:24.126+0000 6960340 20 stack drain pool_spin locked.
2025-05-12T05:45:24.127+0000 6960340 20 stack drain drain 
2025-05-12T05:45:24.127+0000 6960340 20 stack drain worker 0
2025-05-12T05:45:24.127+0000 6960340 20 Event(0xb403b08 nevent=5000 time_id=10).wakeup
2025-05-12T05:45:24.127+0000 6960340 30 Event(0xb403b08 nevent=5000 time_id=10).dispatch_event_external 0x1ffeffdc40 pending 1
2025-05-12T05:45:24.127+0000 6960340 20 stack drain worker 1
2025-05-12T05:45:24.127+0000 6960340 20 Event(0xb432e38 nevent=5000 time_id=19).wakeup
2025-05-12T05:45:24.127+0000 6960340 30 Event(0xb432e38 nevent=5000 time_id=19).dispatch_event_external 0x1ffeffdc40 pending 1
2025-05-12T05:45:24.127+0000 6960340 20 stack drain worker 2
2025-05-12T05:45:24.127+0000 6960340 20 Event(0xb462168 nevent=5000 time_id=38).wakeup
2025-05-12T05:45:24.128+0000 11a40640 30 Event(0xb403b08 nevent=5000 time_id=10).process_events event_wq process is 19 mask is 1
2025-05-12T05:45:24.128+0000 11a40640 30 Event(0xb403b08 nevent=5000 time_id=10).process_events do 0x1ffeffdc40
2025-05-12T05:45:24.128+0000 11a40640 30 stack operator() calling event process
2025-05-12T05:45:24.128+0000 11a40640 30 Event(0xb403b08 nevent=5000 time_id=10).process_events wait second 30 usec 0
2025-05-12T05:45:24.128+0000 1123f640 30 Event(0xb432e38 nevent=5000 time_id=19).process_events event_wq process is 22 mask is 1
2025-05-12T05:45:24.128+0000 1123f640 30 Event(0xb432e38 nevent=5000 time_id=19).process_events do 0x1ffeffdc40
2025-05-12T05:45:24.128+0000 1123f640 30 stack operator() calling event process
2025-05-12T05:45:24.128+0000 1123f640 30 Event(0xb432e38 nevent=5000 time_id=19).process_events wait second 30 usec 0
2025-05-12T05:45:24.128+0000 6960340 30 Event(0xb462168 nevent=5000 time_id=38).dispatch_event_external 0x1ffeffdc40 pending 1
2025-05-12T05:45:24.128+0000 6960340 20 stack drain worker dispatch_event_external done.
2025-05-12T05:45:24.128+0000 6960340 20 stack drain pool_spin unlocked.
2025-05-12T05:45:24.128+0000 be34640 30 Event(0xb462168 nevent=5000 time_id=38).process_events event_wq process is 25 mask is 1
2025-05-12T05:45:24.128+0000 be34640 30 Event(0xb462168 nevent=5000 time_id=38).process_events do 0x1ffeffdc40
2025-05-12T05:45:24.129+0000 be34640 30 stack operator() calling event process
2025-05-12T05:45:24.129+0000 be34640 30 Event(0xb462168 nevent=5000 time_id=38).process_events wait second 30 usec 0
2025-05-12T05:45:24.129+0000 6960340 20 stack drain end.
2025-05-12T05:45:24.129+0000 6960340 20 -- 172.21.15.76:0/888169474 wait: stack drained
2025-05-12T05:45:24.129+0000 6960340 10 -- 172.21.15.76:0/888169474 wait: done.
2025-05-12T05:45:24.129+0000 6960340  1 -- 172.21.15.76:0/888169474 wait complete.
2025-05-12T05:45:24.139+0000 6960340  4 rocksdb: [db/db_impl/db_impl.cc:496] Shutdown: canceling all background work
2025-05-12T05:45:24.188+0000 6960340  4 rocksdb: [db/db_impl/db_impl.cc:704] Shutdown complete
2025-05-12T05:45:24.542+0000 6960340 20 Event(0xb403b08 nevent=5000 time_id=10).wakeup
2025-05-12T05:45:24.542+0000 11a40640 30 Event(0xb403b08 nevent=5000 time_id=10).process_events event_wq process is 19 mask is 1
2025-05-12T05:45:24.544+0000 6960340 20 Event(0xb432e38 nevent=5000 time_id=19).wakeup
2025-05-12T05:45:24.545+0000 1123f640 30 Event(0xb432e38 nevent=5000 time_id=19).process_events event_wq process is 22 mask is 1
2025-05-12T05:45:24.546+0000 6960340 20 Event(0xb462168 nevent=5000 time_id=38).wakeup
2025-05-12T05:45:24.546+0000 be34640 30 Event(0xb462168 nevent=5000 time_id=38).process_events event_wq process is 25 mask is 1

hunged monitor (gap between 05:45:30 to 06:05:48)

2025-05-12T05:45:30.188+0000 a231640 20 stack drain started.
2025-05-12T05:45:30.188+0000 a231640 20 stack drain cur thread id: 170071616
2025-05-12T05:45:30.188+0000 a231640 20 stack drain pool_spin locked.
2025-05-12T05:45:30.188+0000 a231640 20 stack drain drain 
2025-05-12T05:45:30.188+0000 a231640 20 stack drain worker 0
2025-05-12T05:45:30.188+0000 a231640 20 Event(0xb403c68 nevent=5000 time_id=8).wakeup
2025-05-12T05:45:30.188+0000 a231640 30 Event(0xb403c68 nevent=5000 time_id=8).dispatch_event_external 0xa22d310 pending 1
2025-05-12T05:45:30.188+0000 a231640 20 stack drain worker 1
2025-05-12T05:45:30.188+0000 a231640 20 Event(0xb432f98 nevent=5000 time_id=15).wakeup
2025-05-12T05:45:30.188+0000 6960340 10 -- 172.21.15.76:0/3681879607 wait: waiting for dispatch queue
2025-05-12T05:45:30.188+0000 1123f640 30 Event(0xb432f98 nevent=5000 time_id=15).process_events event_wq process is 22 mask is 1
2025-05-12T05:45:30.188+0000 1123f640 30 Event(0xb432f98 nevent=5000 time_id=15).process_events do 0xa22d310
2025-05-12T05:45:30.188+0000 1123f640 30 stack operator() calling event process
2025-05-12T05:45:30.188+0000 1123f640 30 Event(0xb432f98 nevent=5000 time_id=15).process_events wait second 30 usec 0
2025-05-12T05:45:30.188+0000 a231640 30 Event(0xb432f98 nevent=5000 time_id=15).dispatch_event_external 0xa22d310 pending 1
2025-05-12T05:45:30.189+0000 11a40640 30 Event(0xb403c68 nevent=5000 time_id=8).process_events event_wq process is 19 mask is 1
2025-05-12T05:45:30.189+0000 11a40640 30 Event(0xb403c68 nevent=5000 time_id=8).process_events do 0xa22d310
2025-05-12T05:45:30.189+0000 11a40640 30 stack operator() calling event process
2025-05-12T05:45:30.189+0000 11a40640 30 Event(0xb403c68 nevent=5000 time_id=8).process_events wait second 30 usec 0
2025-05-12T05:45:30.189+0000 a231640 20 stack drain worker 2
2025-05-12T05:45:30.189+0000 a231640 20 Event(0xb4622c8 nevent=5000 time_id=42).wakeup
2025-05-12T05:45:30.191+0000 6960340 10 -- 172.21.15.76:0/3681879607 wait: dispatch queue is stopped
2025-05-12T05:45:30.191+0000 6960340  1 -- 172.21.15.76:0/3681879607 shutdown_connections 
2025-05-12T05:45:30.191+0000 6960340  5 -- 172.21.15.76:0/3681879607 shutdown_connections delete 0xb4d17c0
2025-05-12T05:45:30.191+0000 6960340  5 -- 172.21.15.76:0/3681879607 shutdown_connections perf_counter 0xb433480
2025-05-12T05:45:30.191+0000 6960340  5 -- 172.21.15.76:0/3681879607 shutdown_connections deleted_conns size 1
2025-05-12T05:45:30.191+0000 6960340  5 -- 172.21.15.76:0/3681879607 shutdown_connections deleted_conns size 0
2025-05-12T05:45:30.192+0000 6960340  5 -- 172.21.15.76:0/3681879607 shutdown_connections finished
2025-05-12T05:45:30.192+0000 6960340 10 -- 172.21.15.76:0/3681879607 wait: connections closed
2025-05-12T05:45:30.192+0000 6960340 20 stack drain started.
2025-05-12T05:45:30.192+0000 6960340 20 stack drain cur thread id: 110494528
2025-05-12T06:05:48.460+0000 a231640 30 Event(0xb4622c8 nevent=5000 time_id=42).dispatch_event_external 0xa22d310 pending 1
2025-05-12T06:05:48.460+0000 a231640 20 stack drain worker dispatch_event_external done.
2025-05-12T06:05:48.460+0000 a231640 20 stack drain pool_spin unlocked.

so we have:
  • shutdown_connections finished
  • …
  • drain started.
  • drain pool_spin locked.
  • drain end.
  • …
  • wait complete.

vs:
drain started. and drain pool_spin unlocked. and prints:
wait: dispatch queue is stopped

int AsyncMessenger::shutdown()
{
  …
  for (auto &&p : processors)
    p->stop();          // (1) stop WorkerProcessors – kills worker threads

  …
  stack->drain();       // (2) ask the (dead) workers to acknowledge drain
  return 0;
}

p->stop() shuts down each worker’s DispatchQueue and EventCenter,
killing its thread.

// simplified Stack::drain()
pool_spin.lock();
C_drain drain(get_num_worker());
for (Worker* w : workers) {
  w->center.dispatch_event_external(EventCallbackRef(&drain));
}
pool_spin.unlock();
drain.wait();  

Step Action Result
---- --------------------------------------------------------------------------------------- ----------------------------------------
① `p->stop()` All worker threads exit.
② `stack->drain()` queues a `C_drain` callback for each worker. No thread is alive to run the callback.
③ `drain.wait()` blocks forever. Main thread hangs; shutdown stalls.
④ Only an external event (e.g., RocksDB stats dump) unblocks the wait after many minutes. Shutdown finally resumes, much too late.

We have a race condition
p->stop() doesn’t kill the worker thread instantly; it sets a “stopped” flag, wakes the thread, and the thread exits only after it processes any items already in its event queue.
If stack->drain() fires its C_drain callbacks before the worker thread has finished its last pass through EventCenter::process_events(), the callback is processed and the drain completes → no hang.
If the worker reaches its exit point first, it never looks at the new callback, so drain.wait() blocks forever → hang.

NM Updated by Nitzan Mordechai over 1 year ago Actions #4

  • Status changed from New to Fix Under Review
  • Pull request ID set to 63261

RZ Updated by Radoslaw Zarzynski over 1 year ago Actions #5

Sent to QA.

LF Updated by Laura Flores over 1 year ago Actions #6

Still awaiting QA results.

LF Updated by Laura Flores over 1 year ago Actions #7

Awaiting QA

UB Updated by Upkeep Bot over 1 year ago Actions #8

  • Merge Commit set to f287d661babdfa631b883bd1552d789034eb6bfc
  • Fixed In set to v20.3.0-1782-gf287d661ba
  • Upkeep Timestamp set to 2025-07-20T10:39:58+00:00

LF Updated by Laura Flores over 1 year ago Actions #9

  • Status changed from Fix Under Review to Pending Backport

UB Updated by Upkeep Bot over 1 year ago Actions #10

UB Updated by Upkeep Bot over 1 year ago Actions #11

UB Updated by Upkeep Bot over 1 year ago Actions #12

  • Tags (freeform) set to backport_processed

NM Updated by Nitzan Mordechai about 1 year ago Actions #13

  • Status changed from Pending Backport to Resolved

UB Updated by Upkeep Bot 3 months ago Actions #14

  • Tags (freeform) deleted (backport_processed)
  • Upkeep Timestamp changed from 2025-07-20T10:39:58+00:00 to 2026-08-28T01:34:00+00:00

UB Updated by Upkeep Bot about 1 month ago Actions #15

  • Released In set to v21.2.0~2443
  • Upkeep Timestamp changed from 2026-08-28T01:34:00+00:00 to 2026-10-24T01:57:19+00:00
Actions

Also available in: PDF Atom