pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_resetwal prints new OldestXID in wrong circumstances
3+ messages / 2 participants
[nested] [flat]

* pg_resetwal prints new OldestXID in wrong circumstances
@ 2025-11-19 09:52  Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 1 reply; 3+ messages in thread

From: Heikki Linnakangas @ 2025-11-19 09:52 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

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.c
index 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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_resetwal prints new OldestXID in wrong circumstances
@ 2025-11-19 10:05  Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
  parent: Heikki Linnakangas <hlinnaka@iki.fi>
  0 siblings, 1 reply; 3+ messages in thread

From: Bertrand Drouvot @ 2025-11-19 10:05 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

Hi,

On Wed, Nov 19, 2025 at 11:52:31AM +0200, Heikki Linnakangas wrote:
> 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:

Nice catch!

> This seems to have been an oversight when the --oldest-transaction-id option
> was added (commit 74cf7d46a91d).

yeah.

> Before that, OldestXID was reset when the
> --next-transaction-id option was given.
> 
> Fix attached. Barring objections, I will commit and backpatch this.

LGTM, thanks!

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pg_resetwal prints new OldestXID in wrong circumstances
@ 2025-11-19 16:08  Heikki Linnakangas <hlinnaka@iki.fi>
  parent: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Heikki Linnakangas @ 2025-11-19 16:08 UTC (permalink / raw)
  To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On 19/11/2025 12:05, Bertrand Drouvot wrote:
> On Wed, Nov 19, 2025 at 11:52:31AM +0200, Heikki Linnakangas wrote:
>> 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:
> 
> Nice catch!
> 
>> This seems to have been an oversight when the --oldest-transaction-id option
>> was added (commit 74cf7d46a91d).
> 
> yeah.
> 
>> Before that, OldestXID was reset when the
>> --next-transaction-id option was given.
>>
>> Fix attached. Barring objections, I will commit and backpatch this.
> 
> LGTM, thanks!

Committed, thanks!

- Heikki






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2025-11-19 16:08 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-11-19 09:52 pg_resetwal prints new OldestXID in wrong circumstances Heikki Linnakangas <hlinnaka@iki.fi>
2025-11-19 10:05 ` Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
2025-11-19 16:08   ` Heikki Linnakangas <hlinnaka@iki.fi>

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