Change in vdsm[ovirt-3.6]: lib: executor: log task name when discarded

fromani at redhat.com fromani at redhat.com
Wed Nov 11 09:32:23 UTC 2015


Francesco Romani has uploaded a new change for review.

Change subject: lib: executor: log task name when discarded
......................................................................

lib: executor: log task name when discarded

To improve the debuggability of the executor, we
add the name of the task which was stuck/slow
when a worker is discarded.

Doing so it is easier to understand of what's going on
and why workers are being replaced, instead of doing
backtracking in the logs.

Change-Id: I40584ee9a99839a4cb56d2f4d908d274f3a46638
Bug-Url: https://bugzilla.redhat.com/1250839
Backport-To: 3.6
Signed-off-by: Francesco Romani <fromani at redhat.com>
---
M lib/vdsm/executor.py
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/15/48415/1

diff --git a/lib/vdsm/executor.py b/lib/vdsm/executor.py
index cee1e9a..1554920 100644
--- a/lib/vdsm/executor.py
+++ b/lib/vdsm/executor.py
@@ -156,6 +156,7 @@
         self._thread.daemon = True
         self._log.debug('Starting worker %s' % name)
         self._thread.start()
+        self._callable = None
 
     @property
     def name(self):
@@ -182,6 +183,7 @@
     def _execute_task(self):
         callable, timeout = self._executor._next_task()
         discard = self._discard_after(timeout)
+        self._callable = callable
         try:
             callable()
         except Exception:
@@ -192,6 +194,7 @@
             # blocked on callable when we discard it or it just finished.
             # However, we expect that most of times only blocked threads
             # will be discarded.
+            self._callable = None
             if discard is not None:
                 discard.cancel()
             if self._discarded:
@@ -206,9 +209,14 @@
         if self._discarded:
             raise AssertionError("Attempt to discard worker twice")
         self._discarded = True
-        self._log.debug("Worker %s discarded", self.name)
+        self._log.debug("Worker discarded: %s", self)
         self._executor._worker_discarded(self)
 
+    def __str__(self):
+        return "<Worker name=%s task=%s at 0x%x>" % (
+            self.name, self._callable, id(self)
+        )
+
 
 class TaskQueue(object):
     """


-- 
To view, visit https://gerrit.ovirt.org/48415
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I40584ee9a99839a4cb56d2f4d908d274f3a46638
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Francesco Romani <fromani at redhat.com>


More information about the vdsm-patches mailing list