From c092e8767cad0618feee6e6a76071aeb9df3efad Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 28 Sep 2023 15:43:01 +0200 Subject: [PATCH] WIP: pg_resetwal: Corrections around -c option In the documentation for finding a manual value for the -c option based on the files present in the data directory, it was missing a multiplier, like for the other SLRU-based values, and also missing the mention of adding one for the upper value. The value mentioned here is computed as SLRU_PAGES_PER_SEGMENT * COMMIT_TS_XACTS_PER_PAGE = 13088 = 0x3320 Also, the present pg_resetwal code hardcodes the minimum value as 2, which is FrozenTransactionId, but it's not clear why that is allowed. Change that to FirstNormalTransactionId, which matches other xid-related options in pg_resetwal. --- doc/src/sgml/ref/pg_resetwal.sgml | 7 ++++--- src/bin/pg_resetwal/pg_resetwal.c | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/ref/pg_resetwal.sgml b/doc/src/sgml/ref/pg_resetwal.sgml index 08cd3ce5fc..40ea1ff724 100644 --- a/doc/src/sgml/ref/pg_resetwal.sgml +++ b/doc/src/sgml/ref/pg_resetwal.sgml @@ -183,11 +183,12 @@ Options A safe value for the oldest transaction ID for which the commit time can be retrieved (first part) can be determined by looking for the numerically smallest file name in the directory - pg_commit_ts under the data directory. Conversely, a safe + pg_commit_ts under the data directory and then + multiplying by 13088 (0x3320). Conversely, a safe value for the newest transaction ID for which the commit time can be retrieved (second part) can be determined by looking for the numerically - greatest file name in the same directory. The file names are in - hexadecimal. + greatest file name in the same directory, adding one, and then + multiplying by 13088 (0x3320). The file names are in hexadecimal. diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 47e05bd2c9..b3fb94dfbe 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -211,13 +211,13 @@ main(int argc, char *argv[]) exit(1); } - if (set_oldest_commit_ts_xid < 2 && - set_oldest_commit_ts_xid != 0) - pg_fatal("transaction ID (-c) must be either 0 or greater than or equal to 2"); + if (set_oldest_commit_ts_xid < FirstNormalTransactionId && + set_oldest_commit_ts_xid != InvalidTransactionId) + pg_fatal("transaction ID (-c) must be either %u or greater than or equal to %u", InvalidTransactionId, FirstNormalTransactionId); - if (set_newest_commit_ts_xid < 2 && - set_newest_commit_ts_xid != 0) - pg_fatal("transaction ID (-c) must be either 0 or greater than or equal to 2"); + if (set_newest_commit_ts_xid < FirstNormalTransactionId && + set_newest_commit_ts_xid != InvalidTransactionId) + pg_fatal("transaction ID (-c) must be either %u or greater than or equal to %u", InvalidTransactionId, FirstNormalTransactionId); break; case 'o': -- 2.42.0