Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GUC controlling whether to pause recovery if some critical GUCs at replica have smaller value than on primary #501

Open
wants to merge 3 commits into
base: REL_16_STABLE_neon
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/backend/access/transam/xlogrecovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TimestampTz recoveryTargetTime;
const char *recoveryTargetName;
XLogRecPtr recoveryTargetLSN;
int recovery_min_apply_delay = 0;
bool recoveryPauseOnMisconfig = false;
bool allowReplicaMisconfig = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's the GUC for this defined? It was in guc_tables.c in an earlier version of this PR but I don't see it anymore. Is it in the neon extension perhaps? If so, let's add a comment here pointing that out.


/* options formerly taken from recovery.conf for XLOG streaming */
char *PrimaryConnInfo = NULL;
Expand Down Expand Up @@ -4810,8 +4810,11 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
currValue,
minValue)));

if (!recoveryPauseOnMisconfig)
if (!allowReplicaMisconfig)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be

Suggested change
if (!allowReplicaMisconfig)
if (allowReplicaMisconfig)

{
/* Сontinue replication even though it can cause problerms later */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* Сontinue replication even though it can cause problerms later */
/* Сontinue replication even though it can cause problems later */

return;
}

SetRecoveryPause(true);

Expand Down Expand Up @@ -4861,7 +4864,17 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
ConditionVariableCancelSleep();
}

ereport(recoveryPauseOnMisconfig ? FATAL : WARNING,
if (allowReplicaMisconfig)
ereport(WARNING,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("Insufficient parameter settings can cause problems during recovery"),
/* Repeat the detail from above so it's easy to find in the log. */
errdetail("%s = %d is a lower setting than on the primary server, where its value was %d.",
param_name,
currValue,
minValue)));
else
ereport(FATAL,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("recovery aborted because of insufficient parameter settings"),
/* Repeat the detail from above so it's easy to find in the log. */
Expand Down
10 changes: 0 additions & 10 deletions src/backend/utils/misc/guc_tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -1806,16 +1806,6 @@ struct config_bool ConfigureNamesBool[] =
NULL, NULL, NULL
},

{
{"recovery_pause_on_misconfig", PGC_POSTMASTER, WAL_RECOVERY_TARGET,
gettext_noop("Pause recovery if values of critical GUCs at replica are smaller than on primary."),
NULL
},
&recoveryPauseOnMisconfig,
false,
NULL, NULL, NULL
},

{
{"hot_standby", PGC_POSTMASTER, REPLICATION_STANDBY,
gettext_noop("Allows connections and queries during recovery."),
Expand Down
2 changes: 1 addition & 1 deletion src/include/access/xlogrecovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ extern PGDLLIMPORT char *PrimarySlotName;
extern PGDLLIMPORT char *recoveryRestoreCommand;
extern PGDLLIMPORT char *recoveryEndCommand;
extern PGDLLIMPORT char *archiveCleanupCommand;
extern PGDLLIMPORT bool recoveryPauseOnMisconfig;
extern PGDLLIMPORT bool allowReplicaMisconfig;

/* indirectly set via GUC system */
extern PGDLLIMPORT TransactionId recoveryTargetXid;
Expand Down