Double check node allocation in a few more places

Since we operate a lot on cached data we need to make sure that the
state of the node did not check after we've locked it.

This change mainly focuses on checking the `allocated_to` field where
necessary.

Change-Id: I7eb51464f5de88a973ee39e25b57ec9ff2d851da
This commit is contained in:
Simon Westphahl 2023-05-24 18:00:13 +02:00
parent adf44ecdf0
commit 0a858c4be8
No known key found for this signature in database
2 changed files with 6 additions and 1 deletions

View File

@ -589,6 +589,11 @@ class CleanupWorker(BaseCleanupWorker):
"request", node.id)
return
# Make sure the state didn't change on us
if node.allocated_to != req.id:
zk_conn.unlockNode(node)
continue
# If the node is in state init then the launcher that worked
# on the lost request has been interrupted between creating
# the znode and locking/setting to building. In this case the

View File

@ -2650,7 +2650,7 @@ class ZooKeeper(ZooKeeperBase):
continue
# Make sure the state didn't change on us
if node.state != READY:
if node.state != READY or node.allocated_to:
self.unlockNode(node)
continue