From 5c86b60cd2a96033c3475fd14e6207f0f5fea41a Mon Sep 17 00:00:00 2001 From: Oleksii Kliukin Date: Wed, 14 Oct 2015 17:05:09 +0200 Subject: [PATCH] Fix an exception in the (rather unusual) case of attaching Patroni to an existing running replica. --- patroni/postgresql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index 263b58ce..5a857c1c 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -316,7 +316,8 @@ class Postgresql: return True def check_replication_lag(self, last_leader_operation): - return last_leader_operation - self.xlog_position() <= self.config.get('maximum_lag_on_failover', 0) + return (last_leader_operation if last_leader_operation else 0) - self.xlog_position() <=\ + self.config.get('maximum_lag_on_failover', 0) def write_pg_hba(self): with open(os.path.join(self.data_dir, 'pg_hba.conf'), 'a') as f: