postgresql/src/bin
Álvaro Herrera ba25358413
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
..
initdb Translation updates 2024-11-11 13:57:37 +01:00
pg_amcheck Translation updates 2024-11-11 13:57:37 +01:00
pg_archivecleanup Translation updates 2024-11-11 13:57:37 +01:00
pg_basebackup Translation updates 2024-11-11 13:57:37 +01:00
pg_checksums Translation updates 2024-11-11 13:57:37 +01:00
pg_config Translation updates 2024-11-11 13:57:37 +01:00
pg_controldata Translation updates 2024-11-11 13:57:37 +01:00
pg_ctl Translation updates 2024-11-11 13:57:37 +01:00
pg_dump Translation updates 2024-11-11 13:57:37 +01:00
pg_resetwal Translation updates 2024-11-11 13:57:37 +01:00
pg_rewind Avoid deleting critical WAL segments during pg_rewind 2024-11-15 12:53:12 +01:00
pg_test_fsync Translation updates 2024-11-11 13:57:37 +01:00
pg_test_timing Translation updates 2024-11-11 13:57:37 +01:00
pg_upgrade Translation updates 2024-11-11 13:57:37 +01:00
pg_verifybackup Translation updates 2024-11-11 13:57:37 +01:00
pg_waldump Translation updates 2024-11-11 13:57:37 +01:00
pgbench Improve test coverage for changes to inplace-updated catalogs. 2024-06-27 19:21:11 -07:00
pgevent Update copyright for 2021 2021-01-02 13:06:25 -05:00
psql Translation updates 2024-11-11 13:57:37 +01:00
scripts Translation updates 2024-11-11 13:57:37 +01:00
Makefile Add pg_amcheck, a CLI for contrib/amcheck. 2021-03-12 13:00:01 -05:00