| 1 |
# Copyright (c) 2026, PostgreSQL Global Development Group |
| 2 |
|
| 3 |
# Test that unlogged sequences created on a primary can be read after |
| 4 |
# promotion of a standby that replayed their init fork. |
| 5 |
|
| 6 |
use strict; |
| 7 |
use warnings FATAL => 'all'; |
| 8 |
use PostgreSQL::Test::Cluster; |
| 9 |
use PostgreSQL::Test::Utils; |
| 10 |
use Test::More; |
| 11 |
|
| 12 |
my $node_primary = PostgreSQL::Test::Cluster->new('primary'); |
| 13 |
$node_primary->init(allows_streaming => 1); |
| 14 |
$node_primary->start; |
| 15 |
|
| 16 |
my $backup_name = 'my_backup'; |
| 17 |
$node_primary->backup($backup_name); |
| 18 |
|
| 19 |
my $node_standby = PostgreSQL::Test::Cluster->new('standby'); |
| 20 |
$node_standby->init_from_backup($node_primary, $backup_name, |
| 21 |
has_streaming => 1); |
| 22 |
$node_standby->start; |
| 23 |
|
| 24 |
# Create the unlogged sequence after the standby has started, so its init fork |
| 25 |
# is generated by WAL replay on the standby. |
| 26 |
$node_primary->safe_psql('postgres', "CREATE UNLOGGED SEQUENCE ulseq"); |
| 27 |
$node_primary->wait_for_replay_catchup($node_standby); |
| 28 |
|
| 29 |
$node_standby->promote; |
| 30 |
|
| 31 |
is($node_standby->safe_psql('postgres', "SELECT nextval('ulseq')"), |
| 32 |
1, 'unlogged sequence can be read after standby promotion'); |
| 33 |
|
| 34 |
done_testing(); |