1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

Only allow one recovery target setting

The previous recovery.conf regime accepted multiple recovery_target*
settings and used the last one.  This does not translate well to the
general GUC system.  Specifically, under EXEC_BACKEND, the settings
are written out not in any particular order, so the order in which
they were originally set is not available to new processes.

Rather than redesign the GUC system, it was decided to abandon the old
behavior and only allow one recovery target setting.  A second setting
will cause an error.  However, it is allowed to set the same parameter
multiple times or unset a parameter and set a different one.

Discussion: https://www.postgresql.org/message-id/flat/27802171543235530%40iva2-6ec8f0a6115e.qloud-c.yandex.net#701a59c837ad0bf8c244344aaf3ef5a4
This commit is contained in:
Peter Eisentraut
2018-11-28 12:36:49 +01:00
parent eae9143d9a
commit f2cbffc7a6
3 changed files with 62 additions and 32 deletions

View File

@ -3,7 +3,7 @@ use strict;
use warnings;
use PostgresNode;
use TestLib;
use Test::More tests => 9;
use Test::More tests => 8;
# Create and test a standby from given backup, with a certain recovery target.
# Choose $until_lsn later than the transaction commit that causes the row
@ -116,30 +116,22 @@ test_recovery_standby('LSN', 'standby_5', $node_master, \@recovery_params,
"5000", $lsn5);
# Multiple targets
# Last entry has priority (note that an array respects the order of items
# not hashes).
#
# Multiple conflicting settings are not allowed, but setting the same
# parameter multiple times or unsetting a parameter and setting a
# different one is allowed.
@recovery_params = (
"recovery_target_name = '$recovery_name'",
"recovery_target_xid = '$recovery_txid'",
"recovery_target_time = '$recovery_time'");
test_recovery_standby('name + XID + time',
'standby_6', $node_master, \@recovery_params, "3000", $lsn3);
@recovery_params = (
"recovery_target_time = '$recovery_time'",
"recovery_target_name = '$recovery_name'",
"recovery_target_xid = '$recovery_txid'");
test_recovery_standby('time + name + XID',
'standby_7', $node_master, \@recovery_params, "2000", $lsn2);
@recovery_params = (
"recovery_target_xid = '$recovery_txid'",
"recovery_target_time = '$recovery_time'",
"recovery_target_name = '$recovery_name'");
test_recovery_standby('XID + time + name',
'standby_8', $node_master, \@recovery_params, "4000", $lsn4);
@recovery_params = (
"recovery_target_xid = '$recovery_txid'",
"recovery_target_time = '$recovery_time'",
"recovery_target_name = '$recovery_name'",
"recovery_target_lsn = '$recovery_lsn'",);
test_recovery_standby('XID + time + name + LSN',
'standby_9', $node_master, \@recovery_params, "5000", $lsn5);
"recovery_target_name = '$recovery_name'",
"recovery_target_name = ''",
"recovery_target_time = '$recovery_time'");
test_recovery_standby('multiple overriding settings',
'standby_6', $node_master, \@recovery_params, "3000", $lsn3);
my $node_standby = get_new_node('standby_7');
$node_standby->init_from_backup($node_master, 'my_backup', has_restoring => 1);
$node_standby->append_conf('postgresql.conf', "recovery_target_name = '$recovery_name'
recovery_target_time = '$recovery_time'");
command_fails_like(['postgres', '-D', $node_standby->data_dir],
qr/multiple recovery targets specified/,
'multiple conflicting settings');