From 9e7e855d7d84d687108bfbf0d64c0591e4a69cf1 Mon Sep 17 00:00:00 2001 From: Rui Zhao Date: Thu, 10 Sep 2026 10:16:56 +0800 Subject: [PATCH 1/3] Check that a promoted standby keeps the 8-byte OID counter The counter reaches a standby through XLOG_NEXTOID and checkpoint records. Move it past 2^32 on the primary of the timeline-switch test and read it back from the promoted standby. --- 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 4bf111346e..4085d7d04d 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 -- 2.43.7