postgresql/src/bin
Michael Paquier 4fff78f009 Restructure pg_upgrade output directories for better idempotence
38bfae3 has moved the contents written to files by pg_upgrade under a
new directory called pg_upgrade_output.d/ located in the new cluster's
data folder, and it used a simple structure made of two subdirectories
leading to a fixed structure: log/ and dump/.  This design has made
weaker pg_upgrade on repeated calls, as we could get failures when
creating one or more of those directories, while potentially losing the
logs of a previous run (logs are retained automatically on failure, and
cleaned up on success unless --retain is specified).  So a user would
need to clean up pg_upgrade_output.d/ as an extra step for any repeated
calls of pg_upgrade.  The most common scenario here is --check followed
by the actual upgrade, but one could see a failure when specifying an
incorrect input argument value.  Removing entirely the logs would have
the disadvantage of removing all the past information, even if --retain
was specified at some past step.

This result is annoying for a lot of users and automated upgrade flows.
So, rather than requiring a manual removal of pg_upgrade_output.d/, this
redesigns the set of output directories in a more dynamic way, based on
a suggestion from Tom Lane and Daniel Gustafsson.  pg_upgrade_output.d/
is still the base path, but a second directory level is added, mostly
named after an ISO-8601-formatted timestamp (in short human-readable,
with milliseconds appended to the name to avoid any conflicts).  The
logs and dumps are saved within the same subdirectories as previously,
as of log/ and dump/, but these are located inside the subdirectory
named after the timestamp.

The logs of a given run are removed only after a successful run if
--retain is not used, and pg_upgrade_output.d/ is kept if there are any
logs from a previous run.  Note that previously, pg_upgrade would have
kept the logs even after a successful --check but that was inconsistent
compared to the case without --check when using --retain.  The code in
charge of the removal of the output directories is now refactored into a
single routine.

Two TAP tests are added with some --check commands (one failure case and
one success case), to look after the issue fixed here.  Note that the
tests had to be tweaked a bit to fit with the new directory structure so
as it can find any logs generated on failure.  This is still going to
require a change in the buildfarm client for the case where pg_upgrade
is tested without the TAP test, though, but I'll tackle that with a
separate patch where needed.

Reported-by: Tushar Ahuja
Author: Michael Paquier
Reviewed-by: Daniel Gustafsson, Justin Pryzby
Discussion: https://postgr.es/m/77e6ecaa-2785-97aa-f229-4b6e047cbd2b@enterprisedb.com
2022-06-08 10:53:01 +09:00
..
initdb Translation updates 2022-05-16 11:12:42 +02:00
pg_amcheck Don't fail on libpq-generated error reports in pg_amcheck. 2022-06-06 11:26:57 -04:00
pg_archivecleanup Translation updates 2022-05-16 11:12:42 +02:00
pg_basebackup Translation updates 2022-05-16 11:12:42 +02:00
pg_checksums Translation updates 2022-05-16 11:12:42 +02:00
pg_config Translation updates 2022-05-16 11:12:42 +02:00
pg_controldata Translation updates 2022-05-16 11:12:42 +02:00
pg_ctl Translation updates 2022-05-16 11:12:42 +02:00
pg_dump logging: Also add the command prefix to detail and hint messages 2022-05-30 07:26:06 +02:00
pg_resetwal Translation updates 2022-05-16 11:12:42 +02:00
pg_rewind Translation updates 2022-05-16 11:12:42 +02:00
pg_test_fsync Translation updates 2022-05-16 11:12:42 +02:00
pg_test_timing Translation updates 2022-05-16 11:12:42 +02:00
pg_upgrade Restructure pg_upgrade output directories for better idempotence 2022-06-08 10:53:01 +09:00
pg_verifybackup Translation updates 2022-05-16 11:12:42 +02:00
pg_waldump pg_waldump: Improve option parsing error messages 2022-05-20 09:26:21 +02:00
pgbench pgbench: Restore compatibility of --partitions=0 2022-05-18 09:47:38 +09:00
pgevent Update copyright for 2022 2022-01-07 19:04:57 -05:00
psql Fix psql's single transaction mode on client-side errors with -c/-f switches 2022-06-06 11:05:59 +09:00
scripts Translation updates 2022-05-16 11:12:42 +02:00
Makefile Update copyright for 2022 2022-01-07 19:04:57 -05:00