Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot standby delay check recovery to recovery #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion check_postgres.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5634,7 +5634,7 @@ sub check_hot_standby_delay {
}

# check if master and slave comply with the check using pg_is_in_recovery()
my ($master, $slave);
my ($master, $slave, $is_all_recovery);
$SQL = q{SELECT pg_is_in_recovery() AS recovery;};

# Check if master is online (e.g. really a master)
Expand Down Expand Up @@ -5663,6 +5663,12 @@ sub check_hot_standby_delay {
$slave = 2;
}

## If no master detected, assume 1 is master is replicating to 2. The master can also be in recovery mode.
if (! defined $master) {
$master = 1;
$is_all_recovery = 1;
}

## Get xlog positions
my ($moffset, $s_rec_offset, $s_rep_offset, $time_delta);

Expand Down Expand Up @@ -5704,6 +5710,9 @@ sub check_hot_standby_delay {
## On master
if ($version >= 10) {
$SQL = q{SELECT pg_current_wal_lsn() AS location};
if ($is_all_recovery) {
$SQL = q{SELECT pg_last_wal_replay_lsn() AS location};
}
}
else {
$SQL = q{SELECT pg_current_xlog_location() AS location};
Expand Down