Skip to content

Commit 7f75290

Browse files
committed
allow replication session to be set in several backends
1 parent 8fa9faa commit 7f75290

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

contrib/mmts/multimaster.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,7 +3817,7 @@ void MtmSetupReplicationHooks(struct PGLogicalHooks* hooks)
38173817
*/
38183818
void MtmBeginSession(int nodeId)
38193819
{
3820-
MtmLockNode(nodeId, LW_EXCLUSIVE);
3820+
// MtmLockNode(nodeId, LW_EXCLUSIVE);
38213821
Assert(replorigin_session_origin == InvalidRepOriginId);
38223822
replorigin_session_origin = Mtm->nodes[nodeId-1].originId;
38233823
Assert(replorigin_session_origin != InvalidRepOriginId);
@@ -3837,9 +3837,9 @@ void MtmEndSession(int nodeId, bool unlock)
38373837
replorigin_session_origin_lsn = INVALID_LSN;
38383838
replorigin_session_origin_timestamp = 0;
38393839
replorigin_session_reset();
3840-
if (unlock) {
3841-
MtmUnlockNode(nodeId);
3842-
}
3840+
// if (unlock) {
3841+
// MtmUnlockNode(nodeId);
3842+
// }
38433843
MTM_LOG3("%d: End reset replorigin session: %d", MyProcPid, replorigin_session_origin);
38443844
}
38453845
}

src/backend/replication/logical/origin.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,13 +1029,20 @@ replorigin_session_setup(RepOriginId node)
10291029
if (curstate->roident != node)
10301030
continue;
10311031

1032-
else if (curstate->acquired_by != 0)
1033-
{
1034-
ereport(ERROR,
1035-
(errcode(ERRCODE_OBJECT_IN_USE),
1036-
errmsg("replication identifier %d is already active for PID %d",
1037-
curstate->roident, curstate->acquired_by)));
1038-
}
1032+
/*
1033+
* MTM-CRUTCH.
1034+
*
1035+
* Allow multiple backends to setup same replication session.
1036+
*
1037+
* else if (curstate->acquired_by != 0)
1038+
* {
1039+
* ereport(ERROR,
1040+
* (errcode(ERRCODE_OBJECT_IN_USE),
1041+
* errmsg("replication identifier %d is already active for PID %d",
1042+
* curstate->roident, curstate->acquired_by)));
1043+
* }
1044+
*
1045+
*/
10391046

10401047
/* ok, found slot */
10411048
session_replication_state = curstate;

0 commit comments

Comments
 (0)