Skip to content

Commit

Permalink
Timeout better
Browse files Browse the repository at this point in the history
  • Loading branch information
judahrand committed Apr 19, 2022
1 parent 0d6fb63 commit f795486
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pipelinewise/fastsync/commons/tap_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit f795486

Please sign in to comment.