public inbox for [email protected]  
help / color / mirror / Atom feed
From: Hüseyin Demir <[email protected]>
To: David Steele <[email protected]>
Cc: Fujii Masao <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Pg Hackers <[email protected]>
Subject: Re: Improve checks for GUC recovery_target_xid
Date: Mon, 16 Mar 2026 08:44:44 +0100
Message-ID: <CAB5wL7Y=BK7jf7J_shotdBqE9cVy4wgZhk1QuFdoeGonDQwaZg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CAHGQGwG44vZbSoBmg076G+xkR6n=Tj2=q+fVkfP7yEsyF1daFA@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<CAHGQGwEYYad_=fiBkt8HZ=aknXoCUx=2cL7UwSQSYM3nozHMyg@mail.gmail.com>
	<[email protected]>
	<CAHGQGwGuyb--9MBJX__FVJH1=ny0Jh1H+j0Z-_z-28VZy9hK8g@mail.gmail.com>
	<[email protected]>
	<CAHGQGwEhf9byyjhcDEMAd0kPkTdJsO0-HNTnX6Hqs6puBij3-g@mail.gmail.com>
	<[email protected]>
	<CAHGQGwFuXjy7wAkzeDg0cpwsLweyjNO1tACgUWtNdCDtwxZ9hQ@mail.gmail.com>
	<[email protected]>

Hi,


David Steele <[email protected]>, 6 Mar 2026 Cum, 16:01 tarihinde şunu yazdı:
>
> On 3/6/26 14:05, Fujii Masao wrote:
> > On Fri, Mar 6, 2026 at 3:15 PM Michael Paquier <[email protected]> wrote:
> >>
> >> On Fri, Mar 06, 2026 at 12:04:00AM +0900, Fujii Masao wrote:
> >>> Thanks for the patch! It looks good to me. Barring any objections, I
> >>> will commit it.
> >>
> >> Thanks.
> >
> > I've pushed the patch. Thanks!
>
> Thank you and great idea on ALTER SYSTEM. I've been hesitant to add more
> tests in this area because they are so expensive but now I feel much
> better about it. But that's the last for this CF since there is more
> important stuff to be done.
>
> Regards,
> -David

I tried to create tests with the ALTER SYSTEM approach to validate the GUC.

You can review it if it's the correct approach or not. We can create a
new CF record if required for the patch.

Regards.


Attachments:

  [application/octet-stream] v1-0001-add-regression-tests-for-recovery-target-xid-validation.patch (2.1K, 2-v1-0001-add-regression-tests-for-recovery-target-xid-validation.patch)
  download | inline diff:
From a8ff58a7564b4db74385d0130530c45dcc6fd5c7 Mon Sep 17 00:00:00 2001
From: Huseyin Demir <[email protected]>
Date: Mon, 16 Mar 2026 08:27:22 +0100
Subject: [PATCH] Add regression tests for recovery_target_xid GUC validation

Add two test cases to src/test/recovery/t/003_recovery_targets.pl that
verify the check_recovery_target_xid GUC hook correctly rejects invalid
values via ALTER SYSTEM:

  - Non-numeric value ('bogus') -> EINVAL from strtou64
  - Overflow value ('99999999999999999999') -> ERANGE from strtou64

Both tests verify the psql return code and the error message pattern.
Using ALTER SYSTEM on the already-running primary node exercises the same
check hook code path as the conf-edit + pg_ctl-start-failure approach
but is simpler and faster (no standby node creation needed).
---
 src/test/recovery/t/003_recovery_targets.pl | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index e0df1a23423..aba0da150dd 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -240,4 +240,22 @@ ok(!$res, 'invalid timeline target (upper bound check)');
 $log_start =
   $node_standby->wait_for_log("must be between 1 and 4294967295", $log_start);
 
+# Invalid recovery_target_xid via ALTER SYSTEM (non-numeric)
+my $stderr = '';
+$ret = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_xid = 'bogus'",
+	stderr => \$stderr);
+ok($ret != 0, 'ALTER SYSTEM rejects non-numeric recovery_target_xid');
+like($stderr, qr/invalid value for parameter "recovery_target_xid"/,
+	'error message for non-numeric XID value');
+
+# Invalid recovery_target_xid via ALTER SYSTEM (overflow)
+$stderr = '';
+$ret = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_xid = '99999999999999999999'",
+	stderr => \$stderr);
+ok($ret != 0, 'ALTER SYSTEM rejects overflow recovery_target_xid');
+like($stderr, qr/invalid value for parameter "recovery_target_xid"/,
+	'error message for overflow XID value');
+
 done_testing();
-- 
2.50.1 (Apple Git-155)



view thread (20+ messages)  latest in thread

reply

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: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Improve checks for GUC recovery_target_xid
  In-Reply-To: <CAB5wL7Y=BK7jf7J_shotdBqE9cVy4wgZhk1QuFdoeGonDQwaZg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox