mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Rename the parameter recovery_connections to hot_standby, to reduce possible
confusion with streaming-replication settings. Also, change its default value to "off", because of concern about executing new and poorly-tested code during ordinary non-replicating operation. Per discussion. In passing do some minor editing of related documentation.
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.405 2010/04/28 16:10:40 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.406 2010/04/29 21:36:19 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -71,7 +71,7 @@ int XLOGbuffers = 8;
|
||||
int XLogArchiveTimeout = 0;
|
||||
bool XLogArchiveMode = false;
|
||||
char *XLogArchiveCommand = NULL;
|
||||
bool XLogRequestRecoveryConnections = true;
|
||||
bool EnableHotStandby = false;
|
||||
int MaxStandbyDelay = 30;
|
||||
bool fullPageWrites = true;
|
||||
bool log_checkpoints = false;
|
||||
@ -5571,15 +5571,16 @@ GetLatestXLogTime(void)
|
||||
* translation
|
||||
*/
|
||||
#define RecoveryRequiresIntParameter(param_name, currValue, minValue) \
|
||||
{ \
|
||||
do { \
|
||||
if (currValue < minValue) \
|
||||
ereport(ERROR, \
|
||||
(errmsg("recovery connections cannot continue because " \
|
||||
"%s = %u is a lower setting than on WAL source server (value was %u)", \
|
||||
param_name, \
|
||||
currValue, \
|
||||
minValue))); \
|
||||
}
|
||||
(errmsg("hot standby is not possible because " \
|
||||
"%s = %d is a lower setting than on the master server " \
|
||||
"(its value was %d)", \
|
||||
param_name, \
|
||||
currValue, \
|
||||
minValue))); \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
* Check to see if required parameters are set high enough on this server
|
||||
@ -5595,27 +5596,31 @@ CheckRequiredParameterValues(void)
|
||||
if (InArchiveRecovery && ControlFile->wal_level == WAL_LEVEL_MINIMAL)
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("WAL was generated with wal_level='minimal', data may be missing"),
|
||||
errhint("This happens if you temporarily set wal_level='minimal' without taking a new base backup.")));
|
||||
(errmsg("WAL was generated with wal_level=\"minimal\", data may be missing"),
|
||||
errhint("This happens if you temporarily set wal_level=\"minimal\" without taking a new base backup.")));
|
||||
}
|
||||
|
||||
/*
|
||||
* For Hot Standby, the WAL must be generated with 'hot_standby' mode,
|
||||
* and we must have at least as many backend slots as the primary.
|
||||
*/
|
||||
if (InArchiveRecovery && XLogRequestRecoveryConnections)
|
||||
if (InArchiveRecovery && EnableHotStandby)
|
||||
{
|
||||
if (ControlFile->wal_level < WAL_LEVEL_HOT_STANDBY)
|
||||
ereport(ERROR,
|
||||
(errmsg("recovery connections cannot start because wal_level was not set to 'hot_standby' on the WAL source server")));
|
||||
(errmsg("hot standby is not possible because wal_level was not set to \"hot_standby\" on the master server"),
|
||||
errhint("Either set wal_level to \"hot_standby\" on the master, or turn off hot_standby here.")));
|
||||
|
||||
/* We ignore autovacuum_max_workers when we make this test. */
|
||||
RecoveryRequiresIntParameter("max_connections",
|
||||
MaxConnections, ControlFile->MaxConnections);
|
||||
MaxConnections,
|
||||
ControlFile->MaxConnections);
|
||||
RecoveryRequiresIntParameter("max_prepared_xacts",
|
||||
max_prepared_xacts, ControlFile->max_prepared_xacts);
|
||||
max_prepared_xacts,
|
||||
ControlFile->max_prepared_xacts);
|
||||
RecoveryRequiresIntParameter("max_locks_per_xact",
|
||||
max_locks_per_xact, ControlFile->max_locks_per_xact);
|
||||
max_locks_per_xact,
|
||||
ControlFile->max_locks_per_xact);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5953,18 +5958,18 @@ StartupXLOG(void)
|
||||
CheckRequiredParameterValues();
|
||||
|
||||
/*
|
||||
* Initialize recovery connections, if enabled. We won't let backends
|
||||
* Initialize for Hot Standby, if enabled. We won't let backends
|
||||
* in yet, not until we've reached the min recovery point specified in
|
||||
* control file and we've established a recovery snapshot from a
|
||||
* running-xacts WAL record.
|
||||
*/
|
||||
if (InArchiveRecovery && XLogRequestRecoveryConnections)
|
||||
if (InArchiveRecovery && EnableHotStandby)
|
||||
{
|
||||
TransactionId *xids;
|
||||
int nxids;
|
||||
|
||||
ereport(DEBUG1,
|
||||
(errmsg("initializing recovery connections")));
|
||||
(errmsg("initializing for hot standby")));
|
||||
|
||||
InitRecoveryTransactionEnvironment();
|
||||
|
||||
@ -9055,13 +9060,17 @@ StartupProcessMain(void)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Properly accept or ignore signals the postmaster might send us
|
||||
* Properly accept or ignore signals the postmaster might send us.
|
||||
*
|
||||
* Note: ideally we'd not enable handle_standby_sig_alarm unless actually
|
||||
* doing hot standby, but we don't know that yet. Rely on it to not do
|
||||
* anything if it shouldn't.
|
||||
*/
|
||||
pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
|
||||
pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
|
||||
pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
|
||||
pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
|
||||
if (XLogRequestRecoveryConnections)
|
||||
if (EnableHotStandby)
|
||||
pqsignal(SIGALRM, handle_standby_sig_alarm); /* ignored unless
|
||||
* InHotStandby */
|
||||
else
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.67 2010/04/28 00:09:05 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.68 2010/04/29 21:36:19 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -179,18 +179,22 @@ ProcArrayShmemSize(void)
|
||||
size = add_size(size, mul_size(sizeof(PGPROC *), PROCARRAY_MAXPROCS));
|
||||
|
||||
/*
|
||||
* During recovery processing we have a data structure called
|
||||
* During Hot Standby processing we have a data structure called
|
||||
* KnownAssignedXids, created in shared memory. Local data structures are
|
||||
* also created in various backends during GetSnapshotData(),
|
||||
* TransactionIdIsInProgress() and GetRunningTransactionData(). All of the
|
||||
* main structures created in those functions must be identically sized,
|
||||
* since we may at times copy the whole of the data structures around. We
|
||||
* refer to this size as TOTAL_MAX_CACHED_SUBXIDS.
|
||||
*
|
||||
* Ideally we'd only create this structure if we were actually doing
|
||||
* hot standby in the current run, but we don't know that yet at the
|
||||
* time shared memory is being set up.
|
||||
*/
|
||||
#define TOTAL_MAX_CACHED_SUBXIDS \
|
||||
((PGPROC_MAX_CACHED_SUBXIDS + 1) * PROCARRAY_MAXPROCS)
|
||||
|
||||
if (XLogRequestRecoveryConnections)
|
||||
if (EnableHotStandby)
|
||||
{
|
||||
size = add_size(size,
|
||||
mul_size(sizeof(TransactionId),
|
||||
@ -234,7 +238,7 @@ CreateSharedProcArray(void)
|
||||
}
|
||||
|
||||
/* Create or attach to the KnownAssignedXids arrays too, if needed */
|
||||
if (XLogRequestRecoveryConnections)
|
||||
if (EnableHotStandby)
|
||||
{
|
||||
KnownAssignedXids = (TransactionId *)
|
||||
ShmemInitStruct("KnownAssignedXids",
|
||||
|
@ -10,7 +10,7 @@
|
||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.552 2010/04/28 16:10:42 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.553 2010/04/29 21:36:19 tgl Exp $
|
||||
*
|
||||
*--------------------------------------------------------------------
|
||||
*/
|
||||
@ -1222,14 +1222,12 @@ static struct config_bool ConfigureNamesBool[] =
|
||||
},
|
||||
|
||||
{
|
||||
{"recovery_connections", PGC_POSTMASTER, WAL_SETTINGS,
|
||||
gettext_noop("During recovery, allows connections and queries. "
|
||||
" During normal running, causes additional info to be written"
|
||||
" to WAL to enable hot standby mode on WAL standby nodes."),
|
||||
{"hot_standby", PGC_POSTMASTER, WAL_SETTINGS,
|
||||
gettext_noop("Allows connections and queries during recovery."),
|
||||
NULL
|
||||
},
|
||||
&XLogRequestRecoveryConnections,
|
||||
true, NULL, NULL
|
||||
&EnableHotStandby,
|
||||
false, NULL, NULL
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -185,10 +185,10 @@
|
||||
|
||||
# - Hot Standby -
|
||||
|
||||
#recovery_connections = on # allows connections during recovery
|
||||
#max_standby_delay = 30s # max acceptable standby lag (s) to allow queries
|
||||
# to complete without conflict; -1 disables
|
||||
#vacuum_defer_cleanup_age = 0 # num transactions by which cleanup is deferred
|
||||
#hot_standby = off # allows queries during recovery
|
||||
#max_standby_delay = 30s # max acceptable lag (s) to allow queries to
|
||||
# complete without conflict; -1 means forever
|
||||
#vacuum_defer_cleanup_age = 0 # num transactions by which cleanup is deferred
|
||||
|
||||
# - Replication -
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.110 2010/04/28 16:10:43 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.111 2010/04/29 21:36:19 tgl Exp $
|
||||
*/
|
||||
#ifndef XLOG_H
|
||||
#define XLOG_H
|
||||
@ -189,12 +189,13 @@ extern XLogRecPtr XactLastRecEnd;
|
||||
extern int CheckPointSegments;
|
||||
extern int wal_keep_segments;
|
||||
extern int XLOGbuffers;
|
||||
extern int XLogArchiveTimeout;
|
||||
extern bool XLogArchiveMode;
|
||||
extern char *XLogArchiveCommand;
|
||||
extern int XLogArchiveTimeout;
|
||||
extern bool log_checkpoints;
|
||||
extern bool XLogRequestRecoveryConnections;
|
||||
extern bool EnableHotStandby;
|
||||
extern int MaxStandbyDelay;
|
||||
extern bool log_checkpoints;
|
||||
|
||||
/* WAL levels */
|
||||
typedef enum WalLevel
|
||||
{
|
||||
|
Reference in New Issue
Block a user