fix intermediately failing tests
Catchup can be marked completed if got all txns from stashed ordered requests
@@ -429,14 +429,11 @@ class LedgerManager(HasActionQueue):
txnsNum = len(txns) if txns else 0
logger.debug("{} found {} transactions in the catchup from {}"
.format(self, txnsNum, frm))
- if not txns:
- return
-
ledgerId = getattr(rep, f.LEDGER_ID.nm)
ledger_info = self.getLedgerInfoByType(ledgerId)
-
ledger = ledger_info.ledger
+ if txns:
if frm not in ledger_info.recvdCatchupRepliesFrm:
ledger_info.recvdCatchupRepliesFrm[frm] = []
@@ -462,9 +459,11 @@ class LedgerManager(HasActionQueue):
:numProcessed]]))
ledger_info.receivedCatchUpReplies = catchUpReplies[numProcessed:]
- if getattr(ledger_info.catchUpTill, f.SEQ_NO_END.nm) == ledger.size:
- cp = ledger_info.catchUpTill
- self.catchupCompleted(ledgerId, (cp.viewNo, cp.ppSeqNo))
+
+ # This check needs to happen anyway since it might be the case that
+ # just before sending requests for catchup, it might have processed
+ # some ordered requests which might have removed the need for catchup
+ self.mark_catchup_completed_if_possible(ledger_info)
def _processCatchupReplies(self, ledgerId, ledger: Ledger,
catchUpReplies: List):
@@ -582,6 +581,21 @@ class LedgerManager(HasActionQueue):
if str(seqNo) in txns:
return k, rep
+ def mark_catchup_completed_if_possible(self, ledger_info: LedgerInfo):
+ """
+ Checks if the ledger is caught up to the the sequence number
+ specified in the ConsistencyProof, if yes then mark the catchup as
+ done for this ledger.
+ :param ledger_info:
+ :return: True if catchup is done, false otherwise
+ """
+ cp = ledger_info.catchUpTill
+ assert cp
+ if getattr(cp, f.SEQ_NO_END.nm) <= ledger_info.ledger.size:
+ self.catchupCompleted(ledger_info.id, (cp.viewNo, cp.ppSeqNo))
+ return True
+ return False
+
def processConsistencyProofReq(self, req: ConsProofRequest, frm: str):
logger.debug("{} received consistency proof request: {} from {}".
format(self, req, frm))
@@ -741,14 +755,15 @@ class LedgerManager(HasActionQueue):
self.preCatchupClbk(ledger_id)
def startCatchUpProcess(self, ledgerId: int, proof: ConsistencyProof):
- self.do_pre_catchup(ledgerId)
- logger.debug("{} started catching up with consistency proof {}".
- format(self, proof))
if ledgerId not in self.ledgerRegistry:
self.discard(proof, reason="Unknown ledger type {}".
format(ledgerId))
return
+ self.do_pre_catchup(ledgerId)
+ logger.debug("{} started catching up with consistency proof {}".
+ format(self, proof))
+
if proof is None:
self.catchupCompleted(ledgerId)
return
@@ -761,6 +776,10 @@ class LedgerManager(HasActionQueue):
p = ConsistencyProof(*proof)
ledgerInfo.catchUpTill = p
+ if self.mark_catchup_completed_if_possible(ledgerInfo):
+ logger.debug('{} found that ledger {} does not need catchup'.
+ format(self, ledgerId))
+ else:
eligible_nodes = self.nodes_to_request_txns_from
if eligible_nodes:
reqs = self.getCatchupReqs(p)
