From e14a5504c78498a7a91290c52c0cfa0dac86bb68 Mon Sep 17 00:00:00 2001 From: Christoph Brand Date: Tue, 19 Apr 2022 07:24:21 +0200 Subject: [PATCH] feat: minimize standby remaining total calls (#292) Reduce the calls in the recovery service agent checking if standby remaining totals is done by verifying on the tables if the standbys_ready is already set as this is the only thing which happens in the if statement and is computational cheap compared to iterating constantly over the standby_remaining_totals call. Co-authored-by: Vikram Patki <54442035+patkivikram@users.noreply.github.com> --- faust/tables/recovery.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/faust/tables/recovery.py b/faust/tables/recovery.py index d54e586ac..8e5ce888b 100644 --- a/faust/tables/recovery.py +++ b/faust/tables/recovery.py @@ -843,7 +843,10 @@ async def detect_aborted_tx(): await _maybe_signal_recovery_end() - if not self.standby_remaining_total(): + standby_ready = ( + self._standbys_span is None and self.tables.standbys_ready + ) + if not standby_ready and not self.standby_remaining_total(): logger.debug("Completed standby partition fetch") if self._standbys_span: finish_span(self._standbys_span)