public inbox for [email protected]  
help / color / mirror / Atom feed
From: David Steele <[email protected]>
To: Fujii Masao <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Hüseyin Demir <[email protected]>
Cc: Pg Hackers <[email protected]>
Subject: Re: Improve checks for GUC recovery_target_xid
Date: Thu,  5 Mar 2026 13:32:50 +0000 (UTC)
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAHGQGwGuyb--9MBJX__FVJH1=ny0Jh1H+j0Z-_z-28VZy9hK8g@mail.gmail.com>
References: <[email protected]>
	<CAHGQGwEnakTrosMp3Y=Trya4MTC-h8Lqx3FDU1mOALRQ0rz59Q@mail.gmail.com>
	<[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>

On 3/5/26 19:42, Fujii Masao wrote:
> On Thu, Mar 5, 2026 at 5:15 PM David Steele <[email protected]> wrote:
>>
>> On 3/5/26 12:03, Fujii Masao wrote:
>>> On Thu, Mar 5, 2026 at 1:21 PM David Steele <[email protected]> wrote:
>>>> The prior standby is not running because of the invalid config. I
>>>> figured it was better to start clean but when I update the
>>>> recovery_target_timeline tests I was planning to use the same standby
>>>> for all the new tests.
>>>
>>> Alternatively, we can use $node_primary, since ALTER SYSTEM SET with
>>> invalid recovery_target_timeline or recovery_target_xid does not
>>> affect the primary.
>>
>> Well, as it turns out I was using the primary after all because I copied
>> your example and forgot to update the host. Seems weird to set these
>> GUCs on the primary but as long as we get the expected errors I don't
>> suppose it matters.
> 
> Thanks for updating the patch! I've pushed the patch.

Excellent, thank you!

Attached are the test changes for recovery_target_timeline. I can start 
a new thread and add it to the next CF if you like, but since it is just 
test changes maybe we can fast track it.

Regards,
-David
From c70d06d415852e1d7b9bd44d17e9efaf491dfc1d Mon Sep 17 00:00:00 2001
From: David Steele <[email protected]>
Date: Thu, 5 Mar 2026 13:27:58 +0000
Subject: Improve tests for recovery_target_timeline GUC.

Update the recovery_target_timeline tests to match the simpler format
used for recovery_target_xid in bffd7130.
---
 src/test/recovery/t/003_recovery_targets.pl | 68 ++++++---------------
 1 file changed, 20 insertions(+), 48 deletions(-)

diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index 4e36e3a3fb5..047eb13293a 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -190,58 +190,30 @@ like(
 	qr/FATAL: .* recovery ended before configured recovery target was reached/,
 	'recovery end before target reached is a fatal error');
 
-# Invalid timeline target
-$node_standby = PostgreSQL::Test::Cluster->new('standby_9');
-$node_standby->init_from_backup($node_primary, 'my_backup',
-	has_restoring => 1);
-$node_standby->append_conf('postgresql.conf',
-	"recovery_target_timeline = 'bogus'");
-
-$res = run_log(
-	[
-		'pg_ctl',
-		'--pgdata' => $node_standby->data_dir,
-		'--log' => $node_standby->logfile,
-		'start',
-	]);
-ok(!$res, 'invalid timeline target (bogus value)');
-
-my $log_start = $node_standby->wait_for_log("is not a valid number");
-
-# Timeline target out of min range
-$node_standby->append_conf('postgresql.conf',
-	"recovery_target_timeline = '0'");
-
-$res = run_log(
-	[
-		'pg_ctl',
-		'--pgdata' => $node_standby->data_dir,
-		'--log' => $node_standby->logfile,
-		'start',
-	]);
-ok(!$res, 'invalid timeline target (lower bound check)');
-
-$log_start =
-  $node_standby->wait_for_log("must be between 1 and 4294967295", $log_start);
-
-# Timeline target out of max range
-$node_standby->append_conf('postgresql.conf',
-	"recovery_target_timeline = '4294967296'");
+# Invalid recovery_target_timeline tests
+my ($result, $stdout, $stderr) = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_timeline TO 'bogus'");
+like(
+	$stderr,
+	qr/is not a valid number/,
+	"invalid recovery_target_timeline (bogus value)");
 
-$res = run_log(
-	[
-		'pg_ctl',
-		'--pgdata' => $node_standby->data_dir,
-		'--log' => $node_standby->logfile,
-		'start',
-	]);
-ok(!$res, 'invalid timeline target (upper bound check)');
+($result, $stdout, $stderr) = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_timeline TO '0'");
+like(
+	$stderr,
+	qr/must be between 1 and 4294967295/,
+	"invalid recovery_target_timeline (lower bound check)");
 
-$log_start =
-  $node_standby->wait_for_log("must be between 1 and 4294967295", $log_start);
+($result, $stdout, $stderr) = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_timeline TO '4294967296'");
+like(
+	$stderr,
+	qr/must be between 1 and 4294967295/,
+	"invalid recovery_target_timeline (upper bound check)");
 
 # Invalid recovery_target_xid tests
-my ($result, $stdout, $stderr) = $node_primary->psql('postgres',
+($result, $stdout, $stderr) = $node_primary->psql('postgres',
 	"ALTER SYSTEM SET recovery_target_xid TO 'bogus'");
 like(
 	$stderr,
-- 
2.34.1



Attachments:

  [text/plain] recovery-target-timeline-v1.patch (3.1K, 2-recovery-target-timeline-v1.patch)
  download | inline diff:
From c70d06d415852e1d7b9bd44d17e9efaf491dfc1d Mon Sep 17 00:00:00 2001
From: David Steele <[email protected]>
Date: Thu, 5 Mar 2026 13:27:58 +0000
Subject: Improve tests for recovery_target_timeline GUC.

Update the recovery_target_timeline tests to match the simpler format
used for recovery_target_xid in bffd7130.
---
 src/test/recovery/t/003_recovery_targets.pl | 68 ++++++---------------
 1 file changed, 20 insertions(+), 48 deletions(-)

diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index 4e36e3a3fb5..047eb13293a 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -190,58 +190,30 @@ like(
 	qr/FATAL: .* recovery ended before configured recovery target was reached/,
 	'recovery end before target reached is a fatal error');
 
-# Invalid timeline target
-$node_standby = PostgreSQL::Test::Cluster->new('standby_9');
-$node_standby->init_from_backup($node_primary, 'my_backup',
-	has_restoring => 1);
-$node_standby->append_conf('postgresql.conf',
-	"recovery_target_timeline = 'bogus'");
-
-$res = run_log(
-	[
-		'pg_ctl',
-		'--pgdata' => $node_standby->data_dir,
-		'--log' => $node_standby->logfile,
-		'start',
-	]);
-ok(!$res, 'invalid timeline target (bogus value)');
-
-my $log_start = $node_standby->wait_for_log("is not a valid number");
-
-# Timeline target out of min range
-$node_standby->append_conf('postgresql.conf',
-	"recovery_target_timeline = '0'");
-
-$res = run_log(
-	[
-		'pg_ctl',
-		'--pgdata' => $node_standby->data_dir,
-		'--log' => $node_standby->logfile,
-		'start',
-	]);
-ok(!$res, 'invalid timeline target (lower bound check)');
-
-$log_start =
-  $node_standby->wait_for_log("must be between 1 and 4294967295", $log_start);
-
-# Timeline target out of max range
-$node_standby->append_conf('postgresql.conf',
-	"recovery_target_timeline = '4294967296'");
+# Invalid recovery_target_timeline tests
+my ($result, $stdout, $stderr) = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_timeline TO 'bogus'");
+like(
+	$stderr,
+	qr/is not a valid number/,
+	"invalid recovery_target_timeline (bogus value)");
 
-$res = run_log(
-	[
-		'pg_ctl',
-		'--pgdata' => $node_standby->data_dir,
-		'--log' => $node_standby->logfile,
-		'start',
-	]);
-ok(!$res, 'invalid timeline target (upper bound check)');
+($result, $stdout, $stderr) = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_timeline TO '0'");
+like(
+	$stderr,
+	qr/must be between 1 and 4294967295/,
+	"invalid recovery_target_timeline (lower bound check)");
 
-$log_start =
-  $node_standby->wait_for_log("must be between 1 and 4294967295", $log_start);
+($result, $stdout, $stderr) = $node_primary->psql('postgres',
+	"ALTER SYSTEM SET recovery_target_timeline TO '4294967296'");
+like(
+	$stderr,
+	qr/must be between 1 and 4294967295/,
+	"invalid recovery_target_timeline (upper bound check)");
 
 # Invalid recovery_target_xid tests
-my ($result, $stdout, $stderr) = $node_primary->psql('postgres',
+($result, $stdout, $stderr) = $node_primary->psql('postgres',
 	"ALTER SYSTEM SET recovery_target_xid TO 'bogus'");
 like(
 	$stderr,
-- 
2.34.1



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: <[email protected]>

* 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