From f795486b2f397c1c1f9579b97d2907e1fdabc0c4 Mon Sep 17 00:00:00 2001 From: Judah Rand <17158624+judahrand@users.noreply.github.com> Date: Tue, 19 Apr 2022 09:41:22 +0100 Subject: [PATCH] Timeout better --- pipelinewise/fastsync/commons/tap_postgres.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pipelinewise/fastsync/commons/tap_postgres.py b/pipelinewise/fastsync/commons/tap_postgres.py index 70346c1b4..2c2e6fdba 100644 --- a/pipelinewise/fastsync/commons/tap_postgres.py +++ b/pipelinewise/fastsync/commons/tap_postgres.py @@ -356,13 +356,10 @@ def fetch_current_log_pos(self): if self.connection_config.get('replica_host'): # Ensure that the newest LSN availiable on the replica is newer than # the oldest LSN which is deliverable by the replication slot. - time_waited = 0 # seconds - wait_period = 1 # seconds max_time_waited = 60 # seconds + now = time.time() while oldest_lsn > current_lsn: - time.sleep(wait_period) - time_waited += wait_period - if time_waited > max_time_waited: + if time.time() - now > max_time_waited: raise RuntimeError('Replica database is lagging too far behind Primary.') current_lsn = self.get_current_lsn()