Hello Ayal Baron, Allon Mureinik,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/22208

to review the following change.

Change subject: threadPool: Do not keep reference to tasks
......................................................................

threadPool: Do not keep reference to tasks

Worker thread was taking a task from the threadpool queue, run it, and
then hold it until the next task is run. This causes the task and all
objects referenced from it to keep living until the next task is run by
this thread.

This patch ensure that worker thread does not keep referece to tasks
after they were run.

Change-Id: Ib6e024e0727e11a4c98f4e5ede20229d148fdc58
Relates-To: https://bugzilla.redhat.com/1032925
Signed-off-by: Nir Soffer <nsof...@redhat.com>
Reviewed-on: http://gerrit.ovirt.org/22136
Reviewed-by: Ayal Baron <aba...@redhat.com>
Reviewed-by: Allon Mureinik <amure...@redhat.com>
---
M vdsm/storage/threadPool.py
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/22208/1

diff --git a/vdsm/storage/threadPool.py b/vdsm/storage/threadPool.py
index b1f3142..a0e24a2 100644
--- a/vdsm/storage/threadPool.py
+++ b/vdsm/storage/threadPool.py
@@ -191,8 +191,8 @@
         it, calling the callback if any.  """
 
         while not self.__isDying:
+            id, cmd, args, callback = self.__pool.getNextTask()
             try:
-                id, cmd, args, callback = self.__pool.getNextTask()
                 if id is None:  # should retry.
                     pass
                 elif self.__isDying:
@@ -212,6 +212,11 @@
                     self.__pool.setRunningTask(False)
             except Exception:
                 self.log.error("Task %s failed" % repr(cmd), exc_info=True)
+            finally:
+                # Don't keep reference to objects taken from the pool.
+                # Otherwise this thread may keep those object alive until the
+                # next iteration. See BZ#1032925.
+                del id, cmd, args, callback
 
     def goAway(self):
 


-- 
To view, visit http://gerrit.ovirt.org/22208
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6e024e0727e11a4c98f4e5ede20229d148fdc58
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Nir Soffer <nsof...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Ayal Baron <aba...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to