1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Fix GetStrictOldestNonRemovableTransactionId() on standby

e85662df44 implemented GetStrictOldestNonRemovableTransactionId() function
for computation of xid horizon that avoid reporting of false errors.
However, GetStrictOldestNonRemovableTransactionId() uses
GetRunningTransactionData() even on standby leading to an assertion failure.

Given that we decided to ignore KnownAssignedXids and standby can't have
own running xids, we switch to use TransamVariables->nextXid as a xid horizon.

Also, revise the comment regarding ignoring KnownAssignedXids with more
detailed reasoning provided by Heikki.

Reported-by: Heikki Linnakangas
Discussion: https://postgr.es/m/42218c4f-2c8d-40a3-8743-4d34dd0e4cce%40iki.fi
Reviewed-by: Heikki Linnakangas
This commit is contained in:
Alexander Korotkov
2024-08-16 00:17:59 +03:00
parent 9e9a2b7031
commit e2ed7e3227
2 changed files with 40 additions and 5 deletions

View File

@ -10,11 +10,18 @@ use PostgreSQL::Test::Utils;
use Test::More;
# Initialize the primary node
my $node = PostgreSQL::Test::Cluster->new('main');
$node->init;
$node->init(allows_streaming => 1);
$node->start;
# Initialize the streaming standby
my $backup_name = 'my_backup';
$node->backup($backup_name);
my $standby = PostgreSQL::Test::Cluster->new('standby');
$standby->init_from_backup($node, $backup_name, has_streaming => 1);
$standby->start;
# Setup another database
$node->safe_psql("postgres", "CREATE DATABASE other_database;\n");
my $bsession = $node->background_psql('other_database');
@ -39,9 +46,17 @@ my $result = $node->safe_psql("postgres",
# There should be no false negatives
ok($result eq "", "pg_check_visible() detects no errors");
# Run pg_check_visible() on standby
$result = $standby->safe_psql("postgres",
"SELECT * FROM pg_check_visible('vacuum_test');");
# There should be no false negatives either
ok($result eq "", "pg_check_visible() detects no errors");
# Shutdown
$bsession->query_safe("COMMIT;");
$bsession->quit;
$node->stop;
$standby->stop;
done_testing();