From: Heikki Linnakangas <hlinnaka@iki.fi>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: pg_resetwal prints new OldestXID in wrong circumstances
Date: Wed, 19 Nov 2025 11:52:31 +0200
Message-ID: <5461bc85-e684-4531-b4d2-d2e57ad18cba@iki.fi> (raw)
When the --oldest-transaction-id option is used, pg_resetwal doesn't
print the new value like it does for other similar options. For example,
if you use --next-oid and --oldest-transaction-id, only the new NextOID
value is printed:
> $ pg_resetwal --dry-run -D data --next-oid 10 --oldest-transaction-id 100
> Current pg_control values:
>
> ...
>
> Values to be changed:
>
> First log segment after reset: 000000010000000000000005
> NextOID: 10
Printing the new OldestXID value is incorrectly tied to whether the
--next-transaction-id option is given, so this prints it, even though
OldestXID is not being modified:
> $ pg_resetwal --dry-run -D data --next-oid 10 --next-transaction-id 100
> Current pg_control values:
>
> ...
>
>
> Values to be changed:
>
> First log segment after reset: 000000010000000000000005
> NextOID: 10
> NextXID: 100
> OldestXID: 744
> OldestXID's DB: 1
This seems to have been an oversight when the --oldest-transaction-id
option was added (commit 74cf7d46a91d). Before that, OldestXID was reset
when the --next-transaction-id option was given.
Fix attached. Barring objections, I will commit and backpatch this.
- Heikki
Attachments:
[text/x-patch] 0001-Print-new-OldestXID-value-in-pg_resetwal-when-it-s-b.patch (1.1K, ../5461bc85-e684-4531-b4d2-d2e57ad18cba@iki.fi/2-0001-Print-new-OldestXID-value-in-pg_resetwal-when-it-s-b.patch)
download | inline diff:
From 43c0d26852f9fd1b0c7f0b274acb72bc6985414f Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Wed, 19 Nov 2025 11:48:30 +0200
Subject: [PATCH 1/1] Print new OldestXID value in pg_resetwal when it's being
changed
Commit 74cf7d46a91d added the --oldest-transaction-id option to
pg_resetwal, but forgot to update the code that prints all the new
values that are being set. Fix that.
Discussion: XXX
Backpatch-through: 14
---
src/bin/pg_resetwal/pg_resetwal.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.cindex a31e7643cf0..8d5d9805279 100644--- a/src/bin/pg_resetwal/pg_resetwal.c+++ b/src/bin/pg_resetwal/pg_resetwal.c@@ -839,6 +839,10 @@ PrintNewControlValues(void)
{
printf(_("NextXID: %u\n"),
XidFromFullTransactionId(ControlFile.checkPointCopy.nextXid));
+ }++ if (set_oldest_xid != 0)+ {
printf(_("OldestXID: %u\n"),
ControlFile.checkPointCopy.oldestXid);
printf(_("OldestXID's DB: %u\n"),
--
2.47.3
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: hlinnaka@iki.fi, pgsql-bugs@lists.postgresql.org
Subject: Re: pg_resetwal prints new OldestXID in wrong circumstances
In-Reply-To: <5461bc85-e684-4531-b4d2-d2e57ad18cba@iki.fi>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox