Skip to content

Commit 3c48007

Browse files
cbandygkech
authored andcommitted
Consider pg_ctl successful when progress is made
There is a race when using pg_ctl start --wait: - pg_ctl starts Postgres - Postgres begins recovery, detects a parameter requires restart, and exits - pg_ctl reports that Postgres did not start Now we look at the LSN reported by pg_controldata to determine if Postgres made any progress during a "failed" start. Issue: PGO-1945
1 parent 56a6c68 commit 3c48007

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/pgbackrest/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ read -r max_wals <<< "${control##*max_wal_senders setting:}"
249249
echo >> /tmp/postgres.restore.conf "max_wal_senders = '${max_wals}'"
250250
fi
251251
252-
pg_ctl start --silent --timeout=31536000 --wait --options='--config-file=/tmp/postgres.restore.conf'
252+
read -r stopped <<< "${control##*recovery ending location:}"
253+
pg_ctl start --silent --timeout=31536000 --wait --options='--config-file=/tmp/postgres.restore.conf' || failed=$?
254+
[[ "${started-}" == "${stopped}" && -n "${failed-}" ]] && exit "${failed}"
255+
started="${stopped}" && [[ -n "${failed-}" ]] && failed= && continue
253256
fi
254257
255258
recovery=$(psql -Atc "SELECT CASE

0 commit comments

Comments
 (0)