Merge "Use ZK transactions when deleting job request locks"
This commit is contained in:
commit
7d437988bc
@ -329,12 +329,7 @@ class JobRequestQueue(ZooKeeperSimpleBase):
|
|||||||
self.clearParams(request)
|
self.clearParams(request)
|
||||||
except NoNodeError:
|
except NoNodeError:
|
||||||
pass
|
pass
|
||||||
try:
|
self._deleteLock(request.uuid)
|
||||||
# Delete the lock parent node as well
|
|
||||||
path = "/".join([self.LOCK_ROOT, request.uuid])
|
|
||||||
self.kazoo_client.delete(path, recursive=True)
|
|
||||||
except NoNodeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# We use child nodes here so that we don't need to lock the
|
# We use child nodes here so that we don't need to lock the
|
||||||
# request node.
|
# request node.
|
||||||
@ -414,12 +409,22 @@ class JobRequestQueue(ZooKeeperSimpleBase):
|
|||||||
|
|
||||||
# We may have just re-created the lock parent node just after the
|
# We may have just re-created the lock parent node just after the
|
||||||
# scheduler deleted it; therefore we should (re-) delete it.
|
# scheduler deleted it; therefore we should (re-) delete it.
|
||||||
|
self._deleteLock(request.uuid)
|
||||||
|
|
||||||
|
def _deleteLock(self, uuid):
|
||||||
|
# Recursively delete the children and the lock parent node.
|
||||||
|
path = "/".join([self.LOCK_ROOT, uuid])
|
||||||
try:
|
try:
|
||||||
# Delete the lock parent node as well.
|
children = self.kazoo_client.get_children(path)
|
||||||
path = "/".join([self.LOCK_ROOT, request.uuid])
|
|
||||||
self.kazoo_client.delete(path, recursive=True)
|
|
||||||
except NoNodeError:
|
except NoNodeError:
|
||||||
pass
|
# The lock is apparently already gone.
|
||||||
|
return
|
||||||
|
tr = self.kazoo_client.transaction()
|
||||||
|
for child in children:
|
||||||
|
tr.delete("/".join([path, child]))
|
||||||
|
tr.delete(path)
|
||||||
|
# We don't care about the results
|
||||||
|
tr.commit()
|
||||||
|
|
||||||
def unlock(self, request):
|
def unlock(self, request):
|
||||||
if request.lock is None:
|
if request.lock is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user