Re: Improve checks for GUC recovery_target_xid - Mailing list pgsql-hackers

From David Steele
Subject Re: Improve checks for GUC recovery_target_xid
Date
Msg-id 9e8b7ee9-4a16-477a-baa5-0cdf37a04798@pgbackrest.org
Whole thread Raw
In response to Re: Improve checks for GUC recovery_target_xid  (Fujii Masao <masao.fujii@gmail.com>)
Responses Re: Improve checks for GUC recovery_target_xid
List pgsql-hackers
On 2/27/26 08:12, Fujii Masao wrote:
> On Fri, Feb 20, 2026 at 2:42 PM David Steele <david@pgbackrest.org> wrote:
> 
> + GUC_check_errdetail("\"%s\" without epoch must greater than or equal to %u.",
> 
> "must greater" shiould be "must be greater"?

Fixed in v2 attached to the prior email.

> "without epoch" seems not necessary to me.

I guess that depends on whether or not we error if the epoch is present, 
see below.

> + /*
> + * This cast will remove the epoch, if any
> + */
> + xid = (TransactionId) strtou64(*newval, &endp, 0);
> 
> Would it be better to use strtouint32_strict() instead of strtou64()?
> That would allow us to detect invalid XID values larger than 2^32 and
> report an error, similar to what pg_resetwal -x does.

This was my first instinct, but it causes our integration tests to fail 
because pg_current_xact_id() returns the xid with epoch. You can fix 
this by casting pg_current_xact_id()::xid but this seems like a pretty 
big change in usage. I'm OK with it but we'd definitely need to update 
the documentation to match.

What do you think?

Regards
-David



pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Improve checks for GUC recovery_target_xid
Next
From: Michael Paquier
Date:
Subject: Re: BUG: Former primary node might stuck when started as a standby