postgres.git / summary / log / commit / refs
commit 1cd8669179f41b939c08e84ddddd3bdce0e095ea
Author: Michael Paquier <michael@paquier.xyz>
Date: Mon Sep 14 03:05:29 2026 +0000
Check that a promoted standby keeps its 8-byte OID counter
The counter reaches a standby through XLOG_NEXTOID and checkpoint
records. This commit adds a test to move the next OID past the 2^32
limit on a primary and read it back from the promoted standby. This
reuses the same trick as some of the previous tests, with a pg_resetwal
command setting the next OID to be larger than 2^32, combined with a
check based on pg_control_checkpoint().
This closes a testing gap of cb298616463d regarding the replay of
XLOG_NEXTOID, where this WAL record has been updated to pass down an
Oid8 value. By default, regression tests would use OIDs way below the
UINT32_MAX limit.
Author: Rui Zhao <zhaorui126@gmail.com>
Discussion: https://postgr.es/m/CAHWVJhGkb1n_QSS4M=PKJD5HHcwK3KXpFwVxoRVLzAG3j+2fhQ@mail.gmail.com
src/test/recovery/t/004_timeline_switch.pl | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/test/recovery/t/004_timeline_switch.pl b/src/test/recovery/t/004_timeline_switch.pl
index 4bf111346e7..4085d7d04d1 100644
--- a/src/test/recovery/t/004_timeline_switch.pl
+++ b/src/test/recovery/t/004_timeline_switch.pl
@@ -14,6 +14,13 @@ use Test::More;
# Initialize primary node
my $node_primary = PostgreSQL::Test::Cluster->new('primary');
$node_primary->init(allows_streaming => 1);
+
+# Move the OID counter past 2^32, to check below that the promoted standby
+# receives its 8-byte value through WAL.
+my $next_oid = '4295067296'; # 2^32 + 100000
+command_ok(
+ [ 'pg_resetwal', '--next-oid' => $next_oid, $node_primary->data_dir ],
+ 'set an 8-byte OID counter on the primary');
$node_primary->start;
# Take backup
@@ -51,6 +58,16 @@ $node_standby_1->psql(
stdout => \$psql_out);
is($psql_out, 't', "promotion of standby with pg_promote");
+# The OID counter of the promoted standby was set by replaying the
+# XLOG_NEXTOID and checkpoint records of the primary. Force a checkpoint so
+# that pg_control_checkpoint() reports the value in use.
+$node_standby_1->safe_psql('postgres', 'CHECKPOINT');
+is( $node_standby_1->safe_psql(
+ 'postgres',
+ "SELECT next_oid >= '$next_oid'::oid8 FROM pg_control_checkpoint()"),
+ 't',
+ '8-byte OID counter carried over to the promoted standby');
+
# Switch standby 2 to replay from standby 1. During the timeline switch,
# the WAL receiver process on standby 2 should not be stopped, and the
# new primary connection string should not be visible