From 6ed42b5982188096a400c02ba47848c670db71b6 Mon Sep 17 00:00:00 2001 From: glyn Date: Thu, 28 Apr 2016 10:39:45 +0100 Subject: [PATCH] Write correct boolean value for exceede lag, rather than just the lag in seconds. --- pgbouncer_follower.pl | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pgbouncer_follower.pl b/pgbouncer_follower.pl index 51ba2d0..8677071 100755 --- a/pgbouncer_follower.pl +++ b/pgbouncer_follower.pl @@ -145,7 +145,12 @@ sub doAll { } elsif($g_best_config) { if ($g_debug) { - printLogLn($g_logfile, "DEBUG: Found current origin to read config from"); + if ($g_method eq 'slony') { + printLogLn($g_logfile, "DEBUG: Found current origin to read config from"); + } + elsif ($g_method eq 'wal') { + printLogLn($g_logfile, "DEBUG: Read config from all contactable nodes"); + } } last; } @@ -544,17 +549,16 @@ sub loadBinCluster { } # Do the post processing we mentioned above, once we know xlog locations differ # then we can say the apply lag is correct, else it's just there has been no - # activity on the master. In the case the xlog locations differ but apply_lag - # is 0 then it means no WAL has been applied since srver start; cludge here - # and set lag to 1 week. + # activity on the master. In the case the xlog locations differ but apply_lag + # is 0 then it means no WAL has been applied since srver start; we don't know + # a time for lag in this case. else { foreach (@tmp_cluster) { - if (@$_[11] eq $primary_location) { - $apply_lag = 0; - } - else { - $apply_lag = @$_[12] if (@$_[12] > 0); - $apply_lag = 604800 if (@$_[12] = 0); + $apply_lag = false; + if ($g_max_lag > 0) { + if ((@$_[11] ne $primary_location) && (@$_[12] > $g_max_lag || @$_[12] == 0)) { + $apply_lag = true; + } } my @node=(@$_[0],@$_[1],@$_[2],@$_[3],@$_[4],@$_[5],@$_[6],@$_[7],@$_[8],@$_[9],@$_[10],$apply_lag); push(@cluster, \@node); -- 2.39.5