[NEW PATCH] BZ#732652 Avoid logging in the processPool Helper (via gerrit-bot)

Federico Simoncelli fsimonce at redhat.com
Thu Sep 1 09:41:11 UTC 2011


New patch submitted by Federico Simoncelli (fsimonce at redhat.com)

You can review this change at: http://gerrit.usersys.redhat.com/887

commit ae8a9e17f4ccf35ef3a04f2460b906ead97b0e96
Author: Federico Simoncelli <fsimonce at redhat.com>
Date:   Thu Sep 1 09:39:04 2011 +0000

    BZ#732652 Avoid logging in the processPool Helper
    
    Logging can cause a deadlock in a multi-threaded multi-process
    environment therefore closing the logging file descriptors is
    not enough we should also remove all the handlers.
    Reference: http://bugs.python.org/issue6721
    
    Change-Id: Ic70c2b390db23b48f96ba677054039d2773960ae

diff --git a/vdsm/storage/processPool.py b/vdsm/storage/processPool.py
index fc843c4..49c8d5f 100644
--- a/vdsm/storage/processPool.py
+++ b/vdsm/storage/processPool.py
@@ -151,6 +151,13 @@ def _helperMainLoop(pipe, lifeLine, parentLifelineFD):
             except OSError:
                 pass    # Nothing we can do
 
+    # Removing all the handlers from the loggers. This avoid a deadlock on
+    # the logging locks. Multi-process and multi-threading don't mix well.
+    #   - BZ#732652: https://bugzilla.redhat.com/show_bug.cgi?id=732652
+    #   - I6721: http://bugs.python.org/issue6721
+    for log in logging.Logger.manager.loggerDict.values():
+        if hasattr(log, 'handlers'): del log.handlers[:]
+
     poller = select.poll()
     poller.register(lifeLine, 0) # Only SIGERR\SIGHUP
     poller.register(pipe.fileno(), select.EPOLLIN | select.EPOLLPRI)




More information about the vdsm-patches mailing list