From 86b966d950000978e2438f1bd5d9e2bf2e238cd1 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 17 Sep 2020 17:41:03 -0700 Subject: [PATCH] Turn off logging.logThreads when monkey-patched We've seen proxy-servers lock up while trying to log client disconnects. The trouble is that we happen to do this while we're *already* trying to log *something else*. If the timing works out particularly badly, we end up with a double-call to (an eventlet-patched) threading.current_thread(), which needs to enumerate all pthreads, which uses a non-re-entrant lock in CPython. The most expedient solution seems to be disabling logThreads so we never call threading.current_thread(). Change-Id: Ida9418a1bd30ed300a8a850cda567d60c9889ec7 Closes-Bug: #1895739 --- swift/common/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swift/common/utils.py b/swift/common/utils.py index 83417ff9ea..b31e9af9e4 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -554,6 +554,9 @@ def eventlet_monkey_patch(): # if thread is monkey-patched. eventlet.patcher.monkey_patch(all=False, socket=True, select=True, thread=True) + # Trying to log threads while monkey-patched can lead to deadlocks; see + # https://bugs.launchpad.net/swift/+bug/1895739 + logging.logThreads = 0 def noop_libc_function(*args):