This patch works around a deadlock issue that can occasionally happen with chainmaven builds if the hub is using an older version of postgres.
Instead of broadly clearing data by calling taskUnwait, only update the rows we need to. Also, use UpdateProcessor in taskSetWait and taskUnwait --- hub/kojihub.py | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/hub/kojihub.py b/hub/kojihub.py index f076f02..4dc2bcf 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -9742,33 +9742,42 @@ class Host(object): raise koji.AuthError, "This method requires an exclusive session" return True
- def taskUnwait(self,parent): + def taskUnwait(self, parent): """Clear wait data for task""" - c = context.cnx.cursor() #unwait the task - q = """UPDATE task SET waiting='false' WHERE id = %(parent)s""" - context.commit_pending = True - c.execute(q,locals()) + update = UpdateProcessor('task', clauses=['id=%(parent)s'], values=locals()) + update.set(waiting=False) + update.execute() #...and un-await its subtasks - q = """UPDATE task SET awaited='false' WHERE parent=%(parent)s""" - c.execute(q,locals()) + update = UpdateProcessor('task', clauses=['parent=%(parent)s'], values=locals()) + update.set(awaited=False) + update.execute()
- def taskSetWait(self,parent,tasks): + def taskSetWait(self, parent, tasks): """Mark task waiting and subtasks awaited""" - self.taskUnwait(parent) - c = context.cnx.cursor() - #mark tasks awaited - q = """UPDATE task SET waiting='true' WHERE id=%(parent)s""" - context.commit_pending = True - c.execute(q,locals()) + + # mark parent as waiting + update = UpdateProcessor('task', clauses=['id=%(parent)s'], values=locals()) + update.set(waiting=True) + update.execute() + + # mark children awaited if tasks is None: - #wait on all subtasks - q = """UPDATE task SET awaited='true' WHERE parent=%(parent)s""" - c.execute(q,locals()) + # wait on all subtasks + update = UpdateProcessor('task', clauses=['parent=%(parent)s'], values=locals()) + update.set(awaited=True) + update.execute() else: - for id in tasks: - q = """UPDATE task SET awaited='true' WHERE id=%(id)s""" - c.execute(q,locals()) + # wait on specified subtasks + update = UpdateProcessor('task', clauses=['id IN %(tasks)s', 'parent=%(parent)s'], values=locals()) + update.set(awaited=True) + update.execute() + # clear awaited flag on any other child tasks + update = UpdateProcessor('task', values=locals(), + clauses=['id NOT IN %(tasks)s', 'parent=%(parent)s', 'awaited=true']) + update.set(awaited=False) + update.execute() +
def taskWaitCheck(self,parent): """Return status of awaited subtask
On Thu, Oct 8, 2015 at 7:56 PM, Mike McLean mikem@redhat.com wrote:
This patch works around a deadlock issue that can occasionally happen with chainmaven builds if the hub is using an older version of postgres.
I think the patch is missing
On 10/8/15 2:56 PM, Mike McLean wrote:
Instead of broadly clearing data by calling taskUnwait, only update the rows we need to. Also, use UpdateProcessor in taskSetWait and taskUnwait
Looks good to me, +1.
hub/kojihub.py | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/hub/kojihub.py b/hub/kojihub.py index f076f02..4dc2bcf 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -9742,33 +9742,42 @@ class Host(object): raise koji.AuthError, "This method requires an exclusive session" return True
- def taskUnwait(self,parent):
- def taskUnwait(self, parent): """Clear wait data for task"""
c = context.cnx.cursor() #unwait the task
q = """UPDATE task SET waiting='false' WHERE id = %(parent)s"""
context.commit_pending = True
c.execute(q,locals())
update = UpdateProcessor('task', clauses=['id=%(parent)s'], values=locals())
update.set(waiting=False)
update.execute() #...and un-await its subtasks
q = """UPDATE task SET awaited='false' WHERE parent=%(parent)s"""
c.execute(q,locals())
update = UpdateProcessor('task', clauses=['parent=%(parent)s'], values=locals())
update.set(awaited=False)
update.execute()
- def taskSetWait(self,parent,tasks):
- def taskSetWait(self, parent, tasks): """Mark task waiting and subtasks awaited"""
self.taskUnwait(parent)
c = context.cnx.cursor()
#mark tasks awaited
q = """UPDATE task SET waiting='true' WHERE id=%(parent)s"""
context.commit_pending = True
c.execute(q,locals())
# mark parent as waiting
update = UpdateProcessor('task', clauses=['id=%(parent)s'], values=locals())
update.set(waiting=True)
update.execute()
# mark children awaited if tasks is None:
#wait on all subtasks
q = """UPDATE task SET awaited='true' WHERE parent=%(parent)s"""
c.execute(q,locals())
# wait on all subtasks
update = UpdateProcessor('task', clauses=['parent=%(parent)s'], values=locals())
update.set(awaited=True)
update.execute() else:
for id in tasks:
q = """UPDATE task SET awaited='true' WHERE id=%(id)s"""
c.execute(q,locals())
# wait on specified subtasks
update = UpdateProcessor('task', clauses=['id IN %(tasks)s', 'parent=%(parent)s'], values=locals())
update.set(awaited=True)
update.execute()
# clear awaited flag on any other child tasks
update = UpdateProcessor('task', values=locals(),
clauses=['id NOT IN %(tasks)s', 'parent=%(parent)s', 'awaited=true'])
update.set(awaited=False)
update.execute()
def taskWaitCheck(self,parent): """Return status of awaited subtask
On 10/08/2015 11:24 PM, Peter Robinson wrote:
On Thu, Oct 8, 2015 at 7:56 PM, Mike McLean mikem@redhat.com wrote:
This patch works around a deadlock issue that can occasionally happen with chainmaven builds if the hub is using an older version of postgres.
I think the patch is missing
gmail breaks the thread. see: [PATCH] Avoid multiple updates to same rows in taskSetWait
koji-devel mailing list koji-devel@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/koji-devel
koji-devel@lists.fedorahosted.org