Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8bfb231

Browse files
author
Amit Kapila
committed
Prohibit max_slot_wal_keep_size to value other than -1 during upgrade.
We don't want existing slots in the old cluster to get invalidated duringthe upgrade. During an upgrade, we set this variable to -1 via the commandline in an attempt to prevent such invalidations, but users have ways tooverride it. This patch ensures the value is not overridden by the user.Author: Kyotaro HoriguchiReviewed-by: Peter Smith, Alvaro HerreraDiscussion:http://postgr.es/m/20231027.115759.2206827438943188717.horikyota.ntt@gmail.com
1 parent5ba1ac9 commit8bfb231

File tree

4 files changed

+27
-12
lines changed

4 files changed

+27
-12
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,25 @@ check_wal_segment_size(int *newval, void **extra, GucSource source)
20632063
return true;
20642064
}
20652065

2066+
/*
2067+
* GUC check_hook for max_slot_wal_keep_size
2068+
*
2069+
* We don't allow the value of max_slot_wal_keep_size other than -1 during the
2070+
* binary upgrade. See start_postmaster() in pg_upgrade for more details.
2071+
*/
2072+
bool
2073+
check_max_slot_wal_keep_size(int*newval,void**extra,GucSourcesource)
2074+
{
2075+
if (IsBinaryUpgrade&&*newval!=-1)
2076+
{
2077+
GUC_check_errdetail("\"%s\" must be set to -1 during binary upgrade mode.",
2078+
"max_slot_wal_keep_size");
2079+
return false;
2080+
}
2081+
2082+
return true;
2083+
}
2084+
20662085
/*
20672086
* At a checkpoint, how many WAL segments to recycle as preallocated future
20682087
* XLOG segments? Returns the highest segment that should be preallocated.

‎src/backend/replication/slot.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,18 +1424,12 @@ InvalidatePossiblyObsoleteSlot(ReplicationSlotInvalidationCause cause,
14241424
SpinLockRelease(&s->mutex);
14251425

14261426
/*
1427-
* The logical replication slots shouldn't be invalidated as
1428-
* max_slot_wal_keep_sizeGUCis set to -1 during the upgrade.
1429-
*
1430-
*The following is just a sanity check.
1427+
* The logical replication slots shouldn't be invalidated as GUC
1428+
* max_slot_wal_keep_size is set to -1 during thebinaryupgrade. See
1429+
* check_old_cluster_for_valid_slots() where we ensure that no
1430+
*invalidated before the upgrade.
14311431
*/
1432-
if (*invalidated&&SlotIsLogical(s)&&IsBinaryUpgrade)
1433-
{
1434-
ereport(ERROR,
1435-
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1436-
errmsg("replication slots must not be invalidated during the upgrade"),
1437-
errhint("\"max_slot_wal_keep_size\" must be set to -1 during the upgrade"));
1438-
}
1432+
Assert(!(*invalidated&&SlotIsLogical(s)&&IsBinaryUpgrade));
14391433

14401434
if (active_pid!=0)
14411435
{

‎src/backend/utils/misc/guc_tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2845,7 +2845,7 @@ struct config_int ConfigureNamesInt[] =
28452845
},
28462846
&max_slot_wal_keep_size_mb,
28472847
-1,-1,MAX_KILOBYTES,
2848-
NULL,NULL,NULL
2848+
check_max_slot_wal_keep_size,NULL,NULL
28492849
},
28502850

28512851
{

‎src/include/utils/guc_hooks.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ extern bool check_maintenance_io_concurrency(int *newval, void **extra,
8484
externvoidassign_maintenance_io_concurrency(intnewval,void*extra);
8585
externboolcheck_max_connections(int*newval,void**extra,GucSourcesource);
8686
externboolcheck_max_wal_senders(int*newval,void**extra,GucSourcesource);
87+
externboolcheck_max_slot_wal_keep_size(int*newval,void**extra,
88+
GucSourcesource);
8789
externvoidassign_max_wal_size(intnewval,void*extra);
8890
externboolcheck_max_worker_processes(int*newval,void**extra,
8991
GucSourcesource);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp