Skip to content

Commit b0efdfd

Browse files
committed
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 50e2236 commit b0efdfd

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
@@ -248,7 +248,10 @@ read -r max_wals <<< "${control##*max_wal_senders setting:}"
248248
echo >> /tmp/postgres.restore.conf "max_wal_senders = '${max_wals}'"
249249
fi
250250
251-
pg_ctl start --silent --timeout=31536000 --wait --options='--config-file=/tmp/postgres.restore.conf'
251+
read -r stopped <<< "${control##*recovery ending location:}"
252+
pg_ctl start --silent --timeout=31536000 --wait --options='--config-file=/tmp/postgres.restore.conf' || failed=$?
253+
[[ "${started-}" == "${stopped}" && -n "${failed-}" ]] && exit "${failed}"
254+
started="${stopped}" && [[ -n "${failed-}" ]] && failed= && continue
252255
fi
253256
254257
recovery=$(psql -Atc "SELECT CASE

0 commit comments

Comments
 (0)