Skip to content

Commit 84d7ec5

Browse files
author
Michael Paquier
committed
Add comment telling why enforced pg_switch_xlog() is needed
Without that, there is no way to be sure that the segments needed up to the target recovery will be here.
1 parent 9f1424b commit 84d7ec5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sql/restore.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ pgbench -p ${TEST_PGPORT} pgbench > /dev/null 2>&1
125125
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0006-before.out
126126
TARGET_XID=`psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -tAq -c "INSERT INTO tbl0006 VALUES ('inserted') RETURNING (xmin);"`
127127
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
128-
# Enforce segment to be archived to ensure that recovery goes well.
128+
# Enforce segment to be archived to ensure that recovery goes up to the
129+
# wanted point. There is no way to ensure that all segments needed have
130+
# been archived up to the xmin point saved earlier without that.
129131
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c 'SELECT pg_switch_xlog()' > /dev/null 2>&1
132+
# Fast mode is used to ensure that the last segment is archived as well.
130133
pg_ctl stop -m fast > /dev/null 2>&1
131134
pg_arman restore -B ${BACKUP_PATH} --recovery-target-xid="${TARGET_XID}" --quiet;echo $?
132135
pg_ctl start -w -t 600 > /dev/null 2>&1
@@ -151,7 +154,11 @@ pgbench -p ${TEST_PGPORT} pgbench > /dev/null 2>&1
151154
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0007-before.out
152155
TARGET_XID=`psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -tAq -c "INSERT INTO tbl0007 VALUES ('inserted') RETURNING (xmin);"`
153156
pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
157+
# Enforce segment to be archived to ensure that recovery goes up to the
158+
# wanted point. There is no way to ensure that all segments needed have
159+
# been archived up to the xmin point saved earlier without that.
154160
psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c 'SELECT pg_switch_xlog()' > /dev/null 2>&1
161+
# Fast mode is used to ensure that the last segment is archived as well.
155162
pg_ctl stop -m fast > /dev/null 2>&1
156163
pg_arman restore -B ${BACKUP_PATH} --recovery-target-xid="${TARGET_XID}" --recovery-target-inclusive=false --quiet;echo $?
157164
pg_ctl start -w -t 600 > /dev/null 2>&1

0 commit comments

Comments
 (0)