Change in vdsm[master]: threadPool: Do not keep reference to tasks

nsoffer at redhat.com nsoffer at redhat.com
Sat Dec 7 22:58:10 UTC 2013


Nir Soffer has uploaded a new change for review.

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

threadPool: Do not keep reference to tasks

WorkerThread used to take a task from the threadpool queue, run it, and
then hold it until the next task is run. This cause task and all objects
referenced from it to keep living unti the next task is run by this
thread. This patch ensure that task are deleted after they are run.

Change-Id: Ib6e024e0727e11a4c98f4e5ede20229d148fdc58
Relates-To: https://bugzilla.redhat.com/1032925
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M vdsm/storage/threadPool.py
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/22136/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/22136
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib6e024e0727e11a4c98f4e5ede20229d148fdc58
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list