Skip to content

Commit 552fceb

Browse files
committed
Revert "Improve handling of parameter differences in physical replication"
This reverts commit 246f136. That patch wasn't quite complete enough. Discussion: https://www.postgresql.org/message-id/flat/E1jIpJu-0007Ql-CL%40gemulon.postgresql.org
1 parent df3b181 commit 552fceb

File tree

6 files changed

+23
-122
lines changed

6 files changed

+23
-122
lines changed

doc/src/sgml/high-availability.sgml

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,14 +2148,18 @@ LOG: database system is ready to accept read only connections
21482148
</para>
21492149

21502150
<para>
2151-
The settings of some parameters determine the size of shared memory for
2152-
tracking transaction IDs, locks, and prepared transactions. These shared
2153-
memory structures should be no smaller on a standby than on the primary.
2154-
Otherwise, it could happen that the standby runs out of shared memory
2155-
during recovery. For example, if the primary uses a prepared transaction
2156-
but the standby did not allocate any shared memory for tracking prepared
2157-
transactions, then recovery will abort and cannot continue until the
2158-
standby's configuration is changed. The parameters affected are:
2151+
The setting of some parameters on the standby will need reconfiguration
2152+
if they have been changed on the primary. For these parameters,
2153+
the value on the standby must
2154+
be equal to or greater than the value on the primary.
2155+
Therefore, if you want to increase these values, you should do so on all
2156+
standby servers first, before applying the changes to the primary server.
2157+
Conversely, if you want to decrease these values, you should do so on the
2158+
primary server first, before applying the changes to all standby servers.
2159+
If these parameters
2160+
are not set high enough then the standby will refuse to start.
2161+
Higher values can then be supplied and the server
2162+
restarted to begin recovery again. These parameters are:
21592163

21602164
<itemizedlist>
21612165
<listitem>
@@ -2184,34 +2188,6 @@ LOG: database system is ready to accept read only connections
21842188
</para>
21852189
</listitem>
21862190
</itemizedlist>
2187-
2188-
The easiest way to ensure this does not become a problem is to have these
2189-
parameters set on the standbys to values equal to or greater than on the
2190-
primary. Therefore, if you want to increase these values, you should do
2191-
so on all standby servers first, before applying the changes to the
2192-
primary server. Conversely, if you want to decrease these values, you
2193-
should do so on the primary server first, before applying the changes to
2194-
all standby servers. The WAL tracks changes to these parameters on the
2195-
primary, and if a standby processes WAL that indicates that the current
2196-
value on the primary is higher than its own value, it will log a warning, for example:
2197-
<screen>
2198-
WARNING: insufficient setting for parameter max_connections
2199-
DETAIL: max_connections = 80 is a lower setting than on the master server (where its value was 100).
2200-
HINT: Change parameters and restart the server, or there may be resource exhaustion errors sooner or later.
2201-
</screen>
2202-
Recovery will continue but could abort at any time thereafter. (It could
2203-
also never end up failing if the activity on the primary does not actually
2204-
require the full extent of the allocated shared memory resources.) If
2205-
recovery reaches a point where it cannot continue due to lack of shared
2206-
memory, recovery will pause and another warning will be logged, for example:
2207-
<screen>
2208-
WARNING: recovery paused because of insufficient parameter settings
2209-
DETAIL: See earlier in the log about which settings are insufficient.
2210-
HINT: Recovery cannot continue unless the configuration is changed and the server restarted.
2211-
</screen>
2212-
This warning will repeated once a minute. At that point, the settings on
2213-
the standby need to be updated and the instance restarted before recovery
2214-
can continue.
22152191
</para>
22162192

22172193
<para>

src/backend/access/transam/twophase.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,14 +2360,11 @@ PrepareRedoAdd(char *buf, XLogRecPtr start_lsn,
23602360

23612361
/* Get a free gxact from the freelist */
23622362
if (TwoPhaseState->freeGXacts == NULL)
2363-
{
2364-
StandbyParamErrorPauseRecovery();
23652363
ereport(ERROR,
23662364
(errcode(ERRCODE_OUT_OF_MEMORY),
23672365
errmsg("maximum number of prepared transactions reached"),
23682366
errhint("Increase max_prepared_transactions (currently %d).",
23692367
max_prepared_xacts)));
2370-
}
23712368
gxact = TwoPhaseState->freeGXacts;
23722369
TwoPhaseState->freeGXacts = gxact->next;
23732370

src/backend/access/transam/xlog.c

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,6 @@ bool InArchiveRecovery = false;
266266
static bool standby_signal_file_found = false;
267267
static bool recovery_signal_file_found = false;
268268

269-
static bool need_restart_for_parameter_values = false;
270-
271269
/* Was the last xlog file restored from archive, or local? */
272270
static bool restoredFromArchive = false;
273271

@@ -6020,54 +6018,6 @@ SetRecoveryPause(bool recoveryPause)
60206018
SpinLockRelease(&XLogCtl->info_lck);
60216019
}
60226020

6023-
/*
6024-
* If in hot standby, pause recovery because of a parameter conflict.
6025-
*
6026-
* Similar to recoveryPausesHere() but with a different messaging. The user
6027-
* is expected to make the parameter change and restart the server. If they
6028-
* just unpause recovery, they will then run into whatever error is after this
6029-
* function call for the non-hot-standby case.
6030-
*
6031-
* We intentionally do not give advice about specific parameters or values
6032-
* here because it might be misleading. For example, if we run out of lock
6033-
* space, then in the single-server case we would recommend raising
6034-
* max_locks_per_transaction, but in recovery it could equally be the case
6035-
* that max_connections is out of sync with the primary. If we get here, we
6036-
* have already logged any parameter discrepancies in
6037-
* RecoveryRequiresIntParameter(), so users can go back to that and get
6038-
* concrete and accurate information.
6039-
*/
6040-
void
6041-
StandbyParamErrorPauseRecovery(void)
6042-
{
6043-
TimestampTz last_warning = 0;
6044-
6045-
if (!AmStartupProcess() || !need_restart_for_parameter_values)
6046-
return;
6047-
6048-
SetRecoveryPause(true);
6049-
6050-
do
6051-
{
6052-
TimestampTz now = GetCurrentTimestamp();
6053-
6054-
if (TimestampDifferenceExceeds(last_warning, now, 60000))
6055-
{
6056-
ereport(WARNING,
6057-
(errmsg("recovery paused because of insufficient parameter settings"),
6058-
errdetail("See earlier in the log about which settings are insufficient."),
6059-
errhint("Recovery cannot continue unless the configuration is changed and the server restarted.")));
6060-
last_warning = now;
6061-
}
6062-
6063-
pgstat_report_wait_start(WAIT_EVENT_RECOVERY_PAUSE);
6064-
pg_usleep(1000000L); /* 1000 ms */
6065-
pgstat_report_wait_end();
6066-
HandleStartupProcInterrupts();
6067-
}
6068-
while (RecoveryIsPaused());
6069-
}
6070-
60716021
/*
60726022
* When recovery_min_apply_delay is set, we wait long enough to make sure
60736023
* certain record types are applied at least that interval behind the master.
@@ -6247,20 +6197,16 @@ GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream)
62476197
* Note that text field supplied is a parameter name and does not require
62486198
* translation
62496199
*/
6250-
static void
6251-
RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue)
6252-
{
6253-
if (currValue < minValue)
6254-
{
6255-
ereport(WARNING,
6256-
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
6257-
errmsg("insufficient setting for parameter %s", param_name),
6258-
errdetail("%s = %d is a lower setting than on the master server (where its value was %d).",
6259-
param_name, currValue, minValue),
6260-
errhint("Change parameters and restart the server, or there may be resource exhaustion errors sooner or later.")));
6261-
need_restart_for_parameter_values = true;
6262-
}
6263-
}
6200+
#define RecoveryRequiresIntParameter(param_name, currValue, minValue) \
6201+
do { \
6202+
if ((currValue) < (minValue)) \
6203+
ereport(ERROR, \
6204+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), \
6205+
errmsg("hot standby is not possible because %s = %d is a lower setting than on the master server (its value was %d)", \
6206+
param_name, \
6207+
currValue, \
6208+
minValue))); \
6209+
} while(0)
62646210

62656211
/*
62666212
* Check to see if required parameters are set high enough on this server

src/backend/storage/ipc/procarray.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,14 +3654,7 @@ KnownAssignedXidsAdd(TransactionId from_xid, TransactionId to_xid,
36543654
* If it still won't fit then we're out of memory
36553655
*/
36563656
if (head + nxids > pArray->maxKnownAssignedXids)
3657-
{
3658-
StandbyParamErrorPauseRecovery();
3659-
ereport(ERROR,
3660-
(errcode(ERRCODE_OUT_OF_MEMORY),
3661-
errmsg("out of shared memory"),
3662-
errdetail("There are no more KnownAssignedXids slots."),
3663-
errhint("You might need to increase max_connections.")));
3664-
}
3657+
elog(ERROR, "too many KnownAssignedXids");
36653658
}
36663659

36673660
/* Now we can insert the xids into the space starting at head */

src/backend/storage/lmgr/lock.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -965,13 +965,10 @@ LockAcquireExtended(const LOCKTAG *locktag,
965965
if (locallockp)
966966
*locallockp = NULL;
967967
if (reportMemoryError)
968-
{
969-
StandbyParamErrorPauseRecovery();
970968
ereport(ERROR,
971969
(errcode(ERRCODE_OUT_OF_MEMORY),
972970
errmsg("out of shared memory"),
973971
errhint("You might need to increase max_locks_per_transaction.")));
974-
}
975972
else
976973
return LOCKACQUIRE_NOT_AVAIL;
977974
}
@@ -1006,13 +1003,10 @@ LockAcquireExtended(const LOCKTAG *locktag,
10061003
if (locallockp)
10071004
*locallockp = NULL;
10081005
if (reportMemoryError)
1009-
{
1010-
StandbyParamErrorPauseRecovery();
10111006
ereport(ERROR,
10121007
(errcode(ERRCODE_OUT_OF_MEMORY),
10131008
errmsg("out of shared memory"),
10141009
errhint("You might need to increase max_locks_per_transaction.")));
1015-
}
10161010
else
10171011
return LOCKACQUIRE_NOT_AVAIL;
10181012
}
@@ -2834,7 +2828,6 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock)
28342828
{
28352829
LWLockRelease(partitionLock);
28362830
LWLockRelease(&MyProc->backendLock);
2837-
StandbyParamErrorPauseRecovery();
28382831
ereport(ERROR,
28392832
(errcode(ERRCODE_OUT_OF_MEMORY),
28402833
errmsg("out of shared memory"),
@@ -4165,7 +4158,6 @@ lock_twophase_recover(TransactionId xid, uint16 info,
41654158
if (!lock)
41664159
{
41674160
LWLockRelease(partitionLock);
4168-
StandbyParamErrorPauseRecovery();
41694161
ereport(ERROR,
41704162
(errcode(ERRCODE_OUT_OF_MEMORY),
41714163
errmsg("out of shared memory"),
@@ -4231,7 +4223,6 @@ lock_twophase_recover(TransactionId xid, uint16 info,
42314223
elog(PANIC, "lock table corrupted");
42324224
}
42334225
LWLockRelease(partitionLock);
4234-
StandbyParamErrorPauseRecovery();
42354226
ereport(ERROR,
42364227
(errcode(ERRCODE_OUT_OF_MEMORY),
42374228
errmsg("out of shared memory"),
@@ -4524,7 +4515,6 @@ VirtualXactLock(VirtualTransactionId vxid, bool wait)
45244515
{
45254516
LWLockRelease(partitionLock);
45264517
LWLockRelease(&proc->backendLock);
4527-
StandbyParamErrorPauseRecovery();
45284518
ereport(ERROR,
45294519
(errcode(ERRCODE_OUT_OF_MEMORY),
45304520
errmsg("out of shared memory"),

src/include/access/xlog.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ extern XLogRecPtr GetXLogInsertRecPtr(void);
288288
extern XLogRecPtr GetXLogWriteRecPtr(void);
289289
extern bool RecoveryIsPaused(void);
290290
extern void SetRecoveryPause(bool recoveryPause);
291-
extern void StandbyParamErrorPauseRecovery(void);
292291
extern TimestampTz GetLatestXTime(void);
293292
extern TimestampTz GetCurrentChunkReplayStartTime(void);
294293

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy