Commit a760258b authored by Julien Muchembled's avatar Julien Muchembled

master: simplify verification by ignoring completely nodes without readable cells

The scenario that was described in comments was meaningless
because S1 never goes out-of-date.
parent fa63d856
...@@ -66,7 +66,7 @@ class VerificationManager(BaseServiceHandler): ...@@ -66,7 +66,7 @@ class VerificationManager(BaseServiceHandler):
# - there's no unfinished data # - there's no unfinished data
# - just before they return the last tid/oid # - just before they return the last tid/oid
self._askStorageNodesAndWait(Packets.AskLastIDs(), self._askStorageNodesAndWait(Packets.AskLastIDs(),
[x for x in app.nm.getIdentifiedList() if x.isStorage()]) app.nm.getStorageList(only_identified=True))
app.setLastTransaction(app.tm.getLastTID()) app.setLastTransaction(app.tm.getLastTID())
# Just to not return meaningless information in AnswerRecovery. # Just to not return meaningless information in AnswerRecovery.
app.truncate_tid = None app.truncate_tid = None
...@@ -78,28 +78,21 @@ class VerificationManager(BaseServiceHandler): ...@@ -78,28 +78,21 @@ class VerificationManager(BaseServiceHandler):
# Gather all transactions that may have been partially finished. # Gather all transactions that may have been partially finished.
# It's safe to query outdated cells from nodes with readable cells. # It's safe to query outdated cells from nodes with readable cells.
# For other nodes, it's more complicated: # On the other hand, we must ignore temporary data from other nodes:
# 1. pt: U|U ltid: 10 # 1. S1:U S2:U ltid:10
# 2. S1: restart with voted ttid=13 # 2. S1: restart with voted ttid=13
# S2: stop with locked ttid=13 # S2: stop with locked ttid=13
# 3. pt: U|O ltid: 10 # 3. S1:U S2:O ltid:10
# 4. verification drops ttid=13 because it's not locked # 4. verification drops ttid=13 because it's not locked
# 5. new commits -> ltid: 20 # 5. new commits -> ltid:20
# 6. S1 restarted, S2 started # 6. S1 restarted, S2 started
# 7. ttid=13 must be dropped # 7. ttid=13 must be dropped
# And we can't ignore ttid < last tid for all nodes, even if the # Replication will fix them if the data should have been validated.
# master serializes unlock notifications: # And in the case such node had information about locked transactions,
# 1. pt: U.|.U ltid: 15 # a node with readable cells would have unlocked them.
# 2. unlock ttid=18 to S1 node_set = app.pt.getNodeSet(readable=True)
# 3. unlock ttid=20 to S2 assert all(node.isIdentified() for node in node_set), node_set
# 4. S1 stopped before unlocking ttid=18 self._askStorageNodesAndWait(Packets.AskLockedTransactions(), node_set)
# 5. S2 unlocks ttid=20
# 6. back to recovery, S1 started
# 7. verification must validate ttid=18
# So for nodes without any readable cell, and only for them, we only
# check if they have locked transactions. Replication will do the rest.
self._askStorageNodesAndWait(Packets.AskLockedTransactions(),
[x for x in getIdentifiedList() if x.isStorage()])
# Some nodes may have already unlocked these transactions and # Some nodes may have already unlocked these transactions and
# _locked_dict is incomplete, but we can ask them the final tid. # _locked_dict is incomplete, but we can ask them the final tid.
...@@ -142,13 +135,9 @@ class VerificationManager(BaseServiceHandler): ...@@ -142,13 +135,9 @@ class VerificationManager(BaseServiceHandler):
def answerLockedTransactions(self, conn, tid_dict): def answerLockedTransactions(self, conn, tid_dict):
uuid = conn.getUUID() uuid = conn.getUUID()
self._uuid_set.remove(uuid) self._uuid_set.remove(uuid)
app = self.app
node = app.nm.getByUUID(uuid)
vote = any(x[1].isReadable() for x in app.pt.iterNodeCell(node))
for ttid, tid in tid_dict.iteritems(): for ttid, tid in tid_dict.iteritems():
if tid: if tid:
self._locked_dict[ttid] = tid self._locked_dict[ttid] = tid
if vote:
self._voted_dict[ttid].add(uuid) self._voted_dict[ttid].add(uuid)
def answerFinalTID(self, conn, tid): def answerFinalTID(self, conn, tid):
......
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