postgresql/src
Álvaro Herrera 90bcc7c2db
Avoid deleting critical WAL segments during pg_rewind
Previously, in unlucky cases, it was possible for pg_rewind to remove
certain WAL segments from the rewound demoted primary.  In particular
this happens if those files have been marked for archival (i.e., their
.ready files were created) but not yet archived; the newly promoted node
no longer has such files because of them having been recycled, but they
are likely critical for recovery in the demoted node.  If pg_rewind
removes them, recovery is not possible anymore.

Fix this by maintaining a hash table of files in this situation in the
scan that looks for a checkpoint, which the decide_file_actions phase
can consult so that it knows to preserve them.

Backpatch to 14.  The problem also exists in 13, but that branch was not
blessed with commit eb00f1d4bf, so this patch is difficult to apply
there.  Users of older releases will just have to continue to be extra
careful when rewinding.

Co-authored-by: Полина Бунгина (Polina Bungina) <bungina@gmail.com>
Co-authored-by: Alexander Kukushkin <cyberdemn@gmail.com>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Reviewed-by: Atsushi Torikoshi <torikoshia@oss.nttdata.com>
Discussion: https://postgr.es/m/CAAtGL4AhzmBRsEsaDdz7065T+k+BscNadfTqP1NcPmsqwA5HBw@mail.gmail.com
2024-11-15 12:53:12 +01:00
..
backend Proper object locking for GRANT/REVOKE 2024-11-15 11:03:48 +01:00
bin Avoid deleting critical WAL segments during pg_rewind 2024-11-15 12:53:12 +01:00
common Remove unused #include's from bin .c files 2024-11-06 11:11:52 +01:00
fe_utils Remove unused #include's from bin .c files 2024-11-06 11:11:52 +01:00
include Fix race conditions with drop of reused pgstats entries 2024-11-15 11:31:58 +09:00
interfaces libpq: Bail out during SSL/GSS negotiation errors 2024-11-11 10:19:52 +09:00
makefiles Use __attribute__((target(...))) for AVX-512 support. 2024-11-07 13:58:43 -06:00
pl Fix cross-version upgrade tests. 2024-11-11 13:57:21 -05:00
port Move check for USE_AVX512_POPCNT_WITH_RUNTIME_CHECK. 2024-11-08 14:25:28 -06:00
template thread-safety: gmtime_r(), localtime_r() 2024-08-23 07:43:04 +02:00
test Proper object locking for GRANT/REVOKE 2024-11-15 11:03:48 +01:00
timezone Update time zone data files to tzdata release 2024b. 2024-10-29 11:49:38 -04:00
tools Avoid deleting critical WAL segments during pg_rewind 2024-11-15 12:53:12 +01:00
tutorial Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Use __attribute__((target(...))) for AVX-512 support. 2024-11-07 13:58:43 -06:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00