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
Async cleanup races on salt-master/minion SIGTERM shutdown #70730
Task was destroyed but it is pending!
task: <Task pending name='...' coro=<PubServer._drain_loop() running at salt/transport/tcp.py:1775> wait_for=<Future cancelled>>
Task was destroyed but it is pending!
task: <Task pending name='...' coro=<ZeroMQSocketMonitor.consume() running at salt/transport/zeromq.py:1692> wait_for=<Future cancelled>>
PubServer.close() and ZeroMQSocketMonitor.stop() cancel their
background tasks but, being sync calls, do not drive the event loop
long enough for the cancellation to be delivered — the tasks stay in
the cancelling state and asyncio prints the GC warning on loop
teardown. Cosmetic on a one-shot minion but a real resource leak in
contexts that reuse workers.
Symptom 2 — leader ERROR flood on peer departure
During docker compose down on a cluster, the Raft leader logs
dozens of lines per second:
[ERROR ] SaltPeer: failed to send cluster/raft/append-entries to salt-master-N
for every peer that is going away. Two causes:
SaltPeer._send logs ConnectionError / StreamClosedError via log.exception — ERROR level with a traceback — even though
peer-unreachable is the normal shutdown signature.
_publish caches a _TCPPubServerPublisher on the pusher and does
not invalidate it when send() raises. Every subsequent heartbeat
tick reraises against the same dead stream, never reconnecting.
Fix
PubServer.close() routes cancelled drain tasks through _drain_cancelled_tasks, which suppresses the pending-destroy
warning when it cannot drive the loop synchronously.
ZeroMQSocketMonitor.stop() sets task._log_destroy_pending = False
on the cancelled consume task for the same reason.
_publish drops the cached async client on send failure.
SaltPeer._send demotes expected unreachable-peer exceptions
(ConnectionError, OSError, StreamClosedError) to DEBUG;
unexpected exceptions still log at ERROR.
Regression tests in tests/pytests/unit/transport/ and tests/pytests/unit/cluster/consensus/test_peer.py cover each fix.
Activity
Cluster-master stability bundle for 3008.x (8 fixes + regression test…
dwoz commentedon Nov 10, 2026
Resolved by #70756 (merge commit a40f817 on 3008.x).