Commit 4319b532 authored by Julien Muchembled's avatar Julien Muchembled

Fix race condition preventing switching cluster in backup mode

parent cfbd9722
...@@ -127,7 +127,10 @@ class PartitionTable(object): ...@@ -127,7 +127,10 @@ class PartitionTable(object):
except IndexError: except IndexError:
return False return False
def getNodeSet(self): def getNodeSet(self, readable=False):
if readable:
return set(x.getNode() for row in self.partition_list for x in row
if x.isReadable())
return set(x.getNode() for row in self.partition_list for x in row) return set(x.getNode() for row in self.partition_list for x in row)
def getConnectedNodeList(self): def getConnectedNodeList(self):
......
...@@ -90,6 +90,13 @@ class BackupApplication(object): ...@@ -90,6 +90,13 @@ class BackupApplication(object):
# [[tid]] # [[tid]]
self.tid_list = tuple([] for _ in xrange(pt.getPartitions())) self.tid_list = tuple([] for _ in xrange(pt.getPartitions()))
try: try:
while True:
for node in pt.getNodeSet(readable=True):
if not app.isStorageReady(node.getUUID()):
break
else:
break
poll(1)
node, conn, uuid, num_partitions, num_replicas = \ node, conn, uuid, num_partitions, num_replicas = \
bootstrap.getPrimaryConnection(self.connector_handler) bootstrap.getPrimaryConnection(self.connector_handler)
try: try:
...@@ -180,6 +187,8 @@ class BackupApplication(object): ...@@ -180,6 +187,8 @@ class BackupApplication(object):
for cell in pt.getCellList(offset, readable=True): for cell in pt.getCellList(offset, readable=True):
node = cell.getNode() node = cell.getNode()
assert node.isConnected() assert node.isConnected()
if not app.isStorageReady(node.getUUID()):
continue
node_list.append(node) node_list.append(node)
if last_max_tid <= cell.backup_tid: if last_max_tid <= cell.backup_tid:
# This is the last time we can increase # This is the last time we can increase
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment