postgresql/src/bin/pg_rewind
Heikki Linnakangas 3ea8e660c0 Fix more race conditions in the newly-added pg_rewind test.
pg_rewind looks at the control file to check what timeline a server is on.
But promotion doesn't immediately write a checkpoint, it merely writes
an end-of-recovery WAL record. If pg_rewind runs immediately after
promotion, before the checkpoint has completed, it will think think that
the server is still on the earlier timeline. We ran into this issue a long
time ago already, see commit 484a848a73.

It's a bit bogus that pg_rewind doesn't determine the timeline correctly
until the end-of-recovery checkpoint has completed. We probably should
fix that. But for now work around it by waiting for the checkpoint
to complete before running pg_rewind, like we did in commit 484a848a73.

In the passing, tidy up the new test a little bit. Rerder the INSERTs so
that the comments make more sense, remove a spurious CHECKPOINT call after
pg_rewind has already run, and add --debug option, so that if this fails
again, we'll have more data.

Per buildfarm failure at https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=rorqual&dt=2020-12-06%2018%3A32%3A19&stg=pg_rewind-check.
Backpatch to all supported versions.

Discussion: https://www.postgresql.org/message-id/1713707e-e318-761c-d287-5b6a4aa807e8@iki.fi
2020-12-07 14:55:27 +02:00
..
po Translation updates 2020-11-09 12:47:52 +01:00
t Fix more race conditions in the newly-added pg_rewind test. 2020-12-07 14:55:27 +02:00
.gitignore Improve logging of TAP tests. 2015-07-09 13:19:10 +03:00
copy_fetch.c Avoid using potentially-under-aligned page buffers. 2018-09-01 15:27:13 -04:00
datapagemap.c pg_rewind: Improve internationalization 2016-03-28 14:33:00 -03:00
datapagemap.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
fetch.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
fetch.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
file_ops.c Fix handling of files that source server removes during pg_rewind is running. 2018-03-29 04:02:08 +09:00
file_ops.h Fix handling of files that source server removes during pg_rewind is running. 2018-03-29 04:02:08 +09:00
filemap.c Remove useless lstat() call in pg_rewind. 2020-09-06 11:50:41 -04:00
filemap.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
libpq_fetch.c Fix redundant error messages in client tools 2020-11-07 22:45:07 +01:00
logging.c pg_rewing pg_upgrade: Fix translation markers 2016-11-07 09:53:55 -05:00
logging.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
Makefile Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
nls.mk Translation updates 2019-11-11 10:27:46 +01:00
parsexlog.c Fix pg_rewind bugs when rewinding a standby server. 2020-12-03 15:58:02 +02:00
pg_rewind.c Fix pg_rewind bugs when rewinding a standby server. 2020-12-03 15:58:02 +02:00
pg_rewind.h pgindent run for 9.6 2016-06-09 18:02:36 -04:00
timeline.c Update copyright for 2016 2016-01-02 13:33:40 -05:00