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

Commitcc8cdd3

Browse files
committed
Make it possible to drop replciation slots
1 parent828874b commitcc8cdd3

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

‎contrib/multimaster/multimaster--1.0.sql‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ CREATE FUNCTION mm_stop_replication() RETURNS void
99
AS'MODULE_PATHNAME','mm_stop_replication'
1010
LANGUAGE C;
1111

12-
CREATEFUNCTIONmm_disable_node(nodeinteger) RETURNS void
13-
AS'MODULE_PATHNAME','mm_disable_node'
12+
CREATEFUNCTIONmm_drop_node(nodeinteger, drop_slot bool default false) RETURNS void
13+
AS'MODULE_PATHNAME','mm_drop_node'
1414
LANGUAGE C;
1515

‎contrib/multimaster/multimaster.c‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include"storage/proc.h"
4545
#include"utils/syscache.h"
4646
#include"replication/walsender.h"
47+
#include"replication/slot.h"
4748
#include"port/atomics.h"
4849
#include"tcop/utility.h"
4950
#include"sockhub/sockhub.h"
@@ -84,7 +85,7 @@ PG_MODULE_MAGIC;
8485

8586
PG_FUNCTION_INFO_V1(mm_start_replication);
8687
PG_FUNCTION_INFO_V1(mm_stop_replication);
87-
PG_FUNCTION_INFO_V1(mm_disable_node);
88+
PG_FUNCTION_INFO_V1(mm_drop_node);
8889

8990
staticSnapshotDtmGetSnapshot(Snapshotsnapshot);
9091
staticvoidDtmMergeWithGlobalSnapshot(Snapshotsnapshot);
@@ -1216,17 +1217,26 @@ mm_stop_replication(PG_FUNCTION_ARGS)
12161217
}
12171218

12181219
Datum
1219-
mm_disable_node(PG_FUNCTION_ARGS)
1220+
mm_drop_node(PG_FUNCTION_ARGS)
12201221
{
12211222
intnodeId=PG_GETARG_INT32(0);
1222-
if (!BIT_SET(dtm->disabledNodeMask,nodeId))
1223+
booldropSlot=PG_GETARG_BOOL(1);
1224+
if (!BIT_SET(dtm->disabledNodeMask,nodeId-1))
12231225
{
1224-
dtm->disabledNodeMask |= ((int64)1 <<nodeId);
1226+
if (nodeId <=0||nodeId>dtm->nNodes)
1227+
{
1228+
elog(ERROR,"NodeID %d is out of range [1,%d]",nodeId,dtm->nNodes);
1229+
}
1230+
dtm->disabledNodeMask |= ((int64)1 << (nodeId-1));
12251231
dtm->nNodes-=1;
12261232
if (!IsTransactionBlock())
12271233
{
1228-
MMBroadcastUtilityStmt(psprintf("selectmm_disable_node(%d)",nodeId), true);
1234+
MMBroadcastUtilityStmt(psprintf("selectmm_drop_node(%d,%s)",nodeId,dropSlot ?"true" :"false"), true);
12291235
}
1236+
if (dropSlot)
1237+
{
1238+
ReplicationSlotDrop(psprintf("mm_slot_%d",nodeId));
1239+
}
12301240
}
12311241
PG_RETURN_VOID();
12321242
}

‎contrib/pg_dtm/pg_dtm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static TransactionManager DtmTM = {
118118
DtmGetGlobalTransactionId,
119119
PgXidInMVCCSnapshot,
120120
DtmDetectGlobalDeadLock,
121-
GtmGetName
121+
DtmGetName
122122
};
123123

124124
staticchar*DtmServers;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp