postgresql/src/tools
Michael Paquier 4e87c4836a Fix handling of WAL segments ready to be archived during crash recovery
78ea8b5 has fixed an issue related to the recycling of WAL segments on
standbys depending on archive_mode.  However, it has introduced a
regression with the handling of WAL segments ready to be archived during
crash recovery, causing those files to be recycled without getting
archived.

This commit fixes the regression by tracking in shared memory if a live
cluster is either in crash recovery or archive recovery as the handling
of WAL segments ready to be archived is different in both cases (those
WAL segments should not be removed during crash recovery), and by using
this new shared memory state to decide if a segment can be recycled or
not.  Previously, it was not possible to know if a cluster was in crash
recovery or archive recovery as the shared state was able to track only
if recovery was happening or not, leading to the problem.

A set of TAP tests is added to close the gap here, making sure that WAL
segments ready to be archived are correctly handled when a cluster is in
archive or crash recovery with archive_mode set to "on" or "always", for
both standby and primary.

Reported-by: Benoît Lobréau
Author: Jehan-Guillaume de Rorthais
Reviewed-by: Kyotaro Horiguchi, Fujii Masao, Michael Paquier
Discussion: https://postgr.es/m/20200331172229.40ee00dc@firost
Backpatch-through: 9.5
2020-04-24 08:48:28 +09:00
..
editors Make Emacs perl-mode indent more like perltidy. 2019-01-13 11:32:31 -08:00
findoidjoins Update copyrights for 2020 2020-01-01 12:21:45 -05:00
ifaddrs Update copyrights for 2020 2020-01-01 12:21:45 -05:00
make_diff Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
msvc Use a slightly more liberal regex to detect Visual Studio version 2020-04-17 14:44:33 -04:00
perlcheck Stop requiring an explicit return from perl subroutines 2020-04-14 16:55:34 -04:00
pginclude Use perl warnings pragma consistently 2020-04-13 11:55:45 -04:00
pgindent Fix handling of WAL segments ready to be archived during crash recovery 2020-04-24 08:48:28 +09:00
ccsym tools/ccsym: update for modern versions of gcc 2015-01-20 13:02:58 -05:00
check_bison_recursion.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
codelines Fix remaining stray references to CVS. 2010-09-22 19:51:39 -04:00
copyright.pl Remove libpq.rc, use win32ver.rc for libpq 2020-01-15 15:06:12 +01:00
find_badmacros Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
find_static Fix omission of -X (--no-psqlrc) in some psql invocations. 2015-12-28 11:46:43 -05:00
find_typedef Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00
fix-old-flex-code.pl Use perl warnings pragma consistently 2020-04-13 11:55:45 -04:00
gen_keywordlist.pl Update copyrights for 2020 2020-01-01 12:21:45 -05:00
git_changelog Fix incorrect use of term HEAD for Git 2019-10-07 09:44:17 +02:00
git-external-diff Preserve information on use of git-external-diff 2018-05-24 23:45:31 +09:30
make_ctags Improve missing-program error handling in make_ctags and make_etags. 2019-01-13 13:33:50 -05:00
make_etags Improve missing-program error handling in make_ctags and make_etags. 2019-01-13 13:33:50 -05:00
make_mkid Add another pgdefine path check, and a cvs-git change. 2011-08-26 21:52:35 -04:00
PerfectHash.pm Update copyrights for 2020 2020-01-01 12:21:45 -05:00
pgtest pgtest: run clean, build, and check stages separately 2018-07-28 15:34:06 -04:00
RELEASE_CHANGES Add support for automatically updating Unicode derived files 2020-01-09 10:08:14 +01:00
testint128.c Update copyrights for 2020 2020-01-01 12:21:45 -05:00
valgrind.supp Revert "Add valgrind suppressions for wcsrtombs optimizations" 2019-01-19 20:49:51 +01:00
version_stamp.pl Use perl warnings pragma consistently 2020-04-13 11:55:45 -04:00
win32tzlist.pl Use perl's $/ more idiomatically 2020-04-13 12:06:11 -04:00