You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MWorker deadlock via nested SyncWrapper in tcp.PublishServer.publish under async fire_event #69986
Under sustained job-return load on a TCP-transport master, every MWorker
process deadlocks with two threads blocked in threading.Thread.join().
Master CPU drops to idle, find /var/cache/salt/master/jobs -name return.p
throughput falls to near zero, but new TCP connections keep piling up.
Root cause
salt/transport/tcp.py:PublishServer.publish (~line 1943 on 3008.x) wraps
its publisher in SyncWrapper(_TCPPubServerPublisher) via lazy connect().
When publish is invoked from async context — every MWorker._return -> store_job -> fire_event path runs inside the request_handler asyncio loop at salt/transport/zeromq.py:966 — the outer SaltEventSyncWrapper at salt/utils/asynchronous.py:214 sees a running loop, spawns a worker
thread, and .join()s it. That worker thread's _TCPPubServerPublisher
SyncWrapper repeats the detection in its own io_loop, spawns yet another
thread, and both threads block on Thread.join() (asynchronous.py:259). py-spy dump on every MWorker in the wedged state shows the identical
two-thread stack.
Affected branches
3008.x. 3006.x has the same code shape (SyncWrapper + lazy pub_sock) but
uses salt.ext.tornado and @gen.coroutine; a 3006.x patch is a
follow-up (task tracked separately).
Reproduction
Fresh salt-master restart with ~60 already-accepted minions
reconnecting, then tests/monitoring/stress_test_no_api.sh driving state.apply / state.highstate / test.ping / cp.cache_file at
high concurrency. All 5 MWorkers hit the deadlock within seconds of
job processing starting; py-spy on every worker shows the same two
threads pinned at threading.py:1133 (join) inside nested SyncWrapper._wrap frames.
Validation of fix
Fix bypasses the outer SyncWrapper when publish is already running
in an async context (asyncio.get_running_loop() succeeds): use the
raw async _TCPPubServerPublisher directly, cached per running loop
in a WeakKeyDictionary and serialised with a per-loop asyncio.Lock
so concurrent fire_event tasks don't interleave length-prefixed
frames on the shared stream. A StreamClosedError on send drops the
cached publisher and rebuilds once inside the lock. With the patch
applied to a 3008.x master under the same stress load, MWorkers stay
responsive and return-file throughput matches minion completion rate
for the full 10 min run.
Activity
Don't cache per-loop publisher; close it per publish call
Fix nested SyncWrapper deadlock in tcp.TCPPublishServer.publish (3006.x)
Replace fresh-per-call publish with dedicated bg-thread pattern
Fix nested SyncWrapper deadlock in TCP PublishServer
Add tests for TCP PublishServer async-context deadlock (saltstack#69986)
Add changelog for saltstack#69986
Fix 5 root causes surfaced by CI run 31975776712 on PR saltstack#70063
Fix loop-mismatch hang in async PublishServer.publish (saltstack#69986 …
Fix nested SyncWrapper deadlock in tcp.PublishServer.publish
Fix nested SyncWrapper deadlock in tcp.PublishServer.publish
Fix nested SyncWrapper deadlock in tcp.PublishServer.publish
dwoz commentedon Nov 20, 2026
Reopening — #69992 is still in flight.