mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Change default of recovery_target_timeline to 'latest'
This is what one usually wants for recovery and almost always wants for a standby. Discussion: https://www.postgresql.org/message-id/flat/6dd2c23a-4162-8469-410f-bfe146e28c0c@2ndquadrant.com/ Reviewed-by: David Steele <david@pgmasters.net> Reviewed-by: Michael Paquier <michael@paquier.xyz>
This commit is contained in:
parent
373bda61d2
commit
0acb3bc33a
@ -3353,10 +3353,14 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
|
|||||||
Specifies recovering into a particular timeline. The value can be a
|
Specifies recovering into a particular timeline. The value can be a
|
||||||
numeric timeline ID or a special value. The value
|
numeric timeline ID or a special value. The value
|
||||||
<literal>current</literal> recovers along the same timeline that was
|
<literal>current</literal> recovers along the same timeline that was
|
||||||
current when the base backup was taken. That is the default. The
|
current when the base backup was taken. The
|
||||||
value <literal>latest</literal> recovers
|
value <literal>latest</literal> recovers
|
||||||
to the latest timeline found in the archive, which is useful in
|
to the latest timeline found in the archive, which is useful in
|
||||||
a standby server. Other than that you only need to set this parameter
|
a standby server. <literal>latest</literal> is the default.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You usually only need to set this parameter
|
||||||
in complex re-recovery situations, where you need to return to
|
in complex re-recovery situations, where you need to return to
|
||||||
a state that itself was reached after a point-in-time recovery.
|
a state that itself was reached after a point-in-time recovery.
|
||||||
See <xref linkend="backup-timelines"/> for discussion.
|
See <xref linkend="backup-timelines"/> for discussion.
|
||||||
|
@ -690,8 +690,8 @@ protocol to make nodes agree on a serializable transactional order.
|
|||||||
<filename>standby.signal</filename> in the standby's cluster data
|
<filename>standby.signal</filename> in the standby's cluster data
|
||||||
directory. Set <xref linkend="guc-restore-command"/> to a simple command to copy files from
|
directory. Set <xref linkend="guc-restore-command"/> to a simple command to copy files from
|
||||||
the WAL archive. If you plan to have multiple standby servers for high
|
the WAL archive. If you plan to have multiple standby servers for high
|
||||||
availability purposes, set <varname>recovery_target_timeline</varname> to
|
availability purposes, make sure that <varname>recovery_target_timeline</varname> is set to
|
||||||
<literal>latest</literal>, to make the standby server follow the timeline change
|
<literal>latest</literal> (the default), to make the standby server follow the timeline change
|
||||||
that occurs at failover to another standby.
|
that occurs at failover to another standby.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -1024,7 +1024,7 @@ primary_slot_name = 'node_a_slot'
|
|||||||
<para>
|
<para>
|
||||||
If an upstream standby server is promoted to become new master, downstream
|
If an upstream standby server is promoted to become new master, downstream
|
||||||
servers will continue to stream from the new master if
|
servers will continue to stream from the new master if
|
||||||
<varname>recovery_target_timeline</varname> is set to <literal>'latest'</literal>.
|
<varname>recovery_target_timeline</varname> is set to <literal>'latest'</literal> (the default).
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
@ -324,7 +324,7 @@ static bool recoveryStopAfter;
|
|||||||
* file was created.) During a sequential scan we do not allow this value
|
* file was created.) During a sequential scan we do not allow this value
|
||||||
* to decrease.
|
* to decrease.
|
||||||
*/
|
*/
|
||||||
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal = RECOVERY_TARGET_TIMELINE_CONTROLFILE;
|
RecoveryTargetTimeLineGoal recoveryTargetTimeLineGoal = RECOVERY_TARGET_TIMELINE_LATEST;
|
||||||
TimeLineID recoveryTargetTLIRequested = 0;
|
TimeLineID recoveryTargetTLIRequested = 0;
|
||||||
TimeLineID recoveryTargetTLI = 0;
|
TimeLineID recoveryTargetTLI = 0;
|
||||||
static List *expectedTLEs;
|
static List *expectedTLEs;
|
||||||
|
@ -3387,7 +3387,7 @@ static struct config_string ConfigureNamesString[] =
|
|||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
&recovery_target_timeline_string,
|
&recovery_target_timeline_string,
|
||||||
"current",
|
"latest",
|
||||||
check_recovery_target_timeline, assign_recovery_target_timeline, NULL
|
check_recovery_target_timeline, assign_recovery_target_timeline, NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -11028,7 +11028,7 @@ show_data_directory_mode(void)
|
|||||||
static bool
|
static bool
|
||||||
check_recovery_target_timeline(char **newval, void **extra, GucSource source)
|
check_recovery_target_timeline(char **newval, void **extra, GucSource source)
|
||||||
{
|
{
|
||||||
RecoveryTargetTimeLineGoal rttg = RECOVERY_TARGET_TIMELINE_CONTROLFILE;
|
RecoveryTargetTimeLineGoal rttg;
|
||||||
RecoveryTargetTimeLineGoal *myextra;
|
RecoveryTargetTimeLineGoal *myextra;
|
||||||
|
|
||||||
if (strcmp(*newval, "current") == 0)
|
if (strcmp(*newval, "current") == 0)
|
||||||
@ -11037,6 +11037,8 @@ check_recovery_target_timeline(char **newval, void **extra, GucSource source)
|
|||||||
rttg = RECOVERY_TARGET_TIMELINE_LATEST;
|
rttg = RECOVERY_TARGET_TIMELINE_LATEST;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
rttg = RECOVERY_TARGET_TIMELINE_NUMERIC;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
strtoul(*newval, NULL, 0);
|
strtoul(*newval, NULL, 0);
|
||||||
if (errno == EINVAL || errno == ERANGE)
|
if (errno == EINVAL || errno == ERANGE)
|
||||||
@ -11044,7 +11046,6 @@ check_recovery_target_timeline(char **newval, void **extra, GucSource source)
|
|||||||
GUC_check_errdetail("recovery_target_timeline is not a valid number.");
|
GUC_check_errdetail("recovery_target_timeline is not a valid number.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rttg = RECOVERY_TARGET_TIMELINE_NUMERIC;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myextra = (RecoveryTargetTimeLineGoal *) guc_malloc(ERROR, sizeof(RecoveryTargetTimeLineGoal));
|
myextra = (RecoveryTargetTimeLineGoal *) guc_malloc(ERROR, sizeof(RecoveryTargetTimeLineGoal));
|
||||||
|
@ -261,7 +261,7 @@
|
|||||||
# just after the specified recovery target (on)
|
# just after the specified recovery target (on)
|
||||||
# just before the recovery target (off)
|
# just before the recovery target (off)
|
||||||
# (change requires restart)
|
# (change requires restart)
|
||||||
#recovery_target_timeline = 'current' # 'current', 'latest', or timeline ID
|
#recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID
|
||||||
# (change requires restart)
|
# (change requires restart)
|
||||||
#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown'
|
#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown'
|
||||||
# (change requires restart)
|
# (change requires restart)
|
||||||
|
@ -161,7 +161,6 @@ sub create_standby
|
|||||||
$node_standby->append_conf(
|
$node_standby->append_conf(
|
||||||
"postgresql.conf", qq(
|
"postgresql.conf", qq(
|
||||||
primary_conninfo='$connstr_master application_name=rewind_standby'
|
primary_conninfo='$connstr_master application_name=rewind_standby'
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$node_standby->set_standby_mode();
|
$node_standby->set_standby_mode();
|
||||||
@ -273,7 +272,6 @@ sub run_pg_rewind
|
|||||||
$node_master->append_conf(
|
$node_master->append_conf(
|
||||||
'postgresql.conf', qq(
|
'postgresql.conf', qq(
|
||||||
primary_conninfo='port=$port_standby'
|
primary_conninfo='port=$port_standby'
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$node_master->set_standby_mode();
|
$node_master->set_standby_mode();
|
||||||
|
@ -51,7 +51,6 @@ my $connstr_1 = $node_standby_1->connstr;
|
|||||||
$node_standby_2->append_conf(
|
$node_standby_2->append_conf(
|
||||||
'postgresql.conf', qq(
|
'postgresql.conf', qq(
|
||||||
primary_conninfo='$connstr_1 application_name=@{[$node_standby_2->name]}'
|
primary_conninfo='$connstr_1 application_name=@{[$node_standby_2->name]}'
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
));
|
||||||
$node_standby_2->restart;
|
$node_standby_2->restart;
|
||||||
|
|
||||||
|
@ -229,10 +229,6 @@ is($psql_rc, '0', "Restore of prepared transaction on promoted standby");
|
|||||||
|
|
||||||
# restart old master as new standby
|
# restart old master as new standby
|
||||||
$cur_standby->enable_streaming($cur_master);
|
$cur_standby->enable_streaming($cur_master);
|
||||||
$cur_standby->append_conf(
|
|
||||||
'postgresql.conf', qq(
|
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
|
||||||
$cur_standby->start;
|
$cur_standby->start;
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -267,10 +263,6 @@ is($psql_out, '1',
|
|||||||
|
|
||||||
# restart old master as new standby
|
# restart old master as new standby
|
||||||
$cur_standby->enable_streaming($cur_master);
|
$cur_standby->enable_streaming($cur_master);
|
||||||
$cur_standby->append_conf(
|
|
||||||
'postgresql.conf', qq(
|
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
|
||||||
$cur_standby->start;
|
$cur_standby->start;
|
||||||
|
|
||||||
$cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_11'");
|
$cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_11'");
|
||||||
@ -307,10 +299,6 @@ is($psql_out, '1',
|
|||||||
|
|
||||||
# restart old master as new standby
|
# restart old master as new standby
|
||||||
$cur_standby->enable_streaming($cur_master);
|
$cur_standby->enable_streaming($cur_master);
|
||||||
$cur_standby->append_conf(
|
|
||||||
'postgresql.conf', qq(
|
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
|
||||||
$cur_standby->start;
|
$cur_standby->start;
|
||||||
|
|
||||||
$cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_12'");
|
$cur_master->psql('postgres', "COMMIT PREPARED 'xact_009_12'");
|
||||||
|
@ -119,10 +119,6 @@ is($psql_out, '8128', "Visible");
|
|||||||
# restore state
|
# restore state
|
||||||
($node_master, $node_standby) = ($node_standby, $node_master);
|
($node_master, $node_standby) = ($node_standby, $node_master);
|
||||||
$node_standby->enable_streaming($node_master);
|
$node_standby->enable_streaming($node_master);
|
||||||
$node_standby->append_conf(
|
|
||||||
'postgresql.conf', qq(
|
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
|
||||||
$node_standby->start;
|
$node_standby->start;
|
||||||
$node_standby->psql(
|
$node_standby->psql(
|
||||||
'postgres',
|
'postgres',
|
||||||
@ -170,10 +166,6 @@ is($psql_out, '-1', "Not visible");
|
|||||||
# restore state
|
# restore state
|
||||||
($node_master, $node_standby) = ($node_standby, $node_master);
|
($node_master, $node_standby) = ($node_standby, $node_master);
|
||||||
$node_standby->enable_streaming($node_master);
|
$node_standby->enable_streaming($node_master);
|
||||||
$node_standby->append_conf(
|
|
||||||
'postgresql.conf', qq(
|
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
|
||||||
$node_standby->start;
|
$node_standby->start;
|
||||||
$psql_rc = $node_master->psql('postgres', "COMMIT PREPARED 'xact_012_1'");
|
$psql_rc = $node_master->psql('postgres', "COMMIT PREPARED 'xact_012_1'");
|
||||||
is($psql_rc, '0',
|
is($psql_rc, '0',
|
||||||
@ -211,10 +203,6 @@ is($psql_out, '-1', "Not visible");
|
|||||||
# restore state
|
# restore state
|
||||||
($node_master, $node_standby) = ($node_standby, $node_master);
|
($node_master, $node_standby) = ($node_standby, $node_master);
|
||||||
$node_standby->enable_streaming($node_master);
|
$node_standby->enable_streaming($node_master);
|
||||||
$node_standby->append_conf(
|
|
||||||
'postgresql.conf', qq(
|
|
||||||
recovery_target_timeline='latest'
|
|
||||||
));
|
|
||||||
$node_standby->start;
|
$node_standby->start;
|
||||||
$psql_rc = $node_master->psql('postgres', "ROLLBACK PREPARED 'xact_012_1'");
|
$psql_rc = $node_master->psql('postgres', "ROLLBACK PREPARED 'xact_012_1'");
|
||||||
is($psql_rc, '0',
|
is($psql_rc, '0',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user