Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit af70e59

Browse files
committed
Init mapping for originIds in walsender
1 parent fb7dec4 commit af70e59

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

multimaster.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3587,6 +3587,7 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
35873587
ListCell *param;
35883588
bool recoveryCompleted = false;
35893589
ulong64 recoveryStartPos = INVALID_LSN;
3590+
int i;
35903591

35913592
MtmIsRecoverySession = false;
35923593
Mtm->nodes[MtmReplicationNodeId-1].senderPid = MyProcPid;
@@ -3632,6 +3633,28 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
36323633
MTM_LOG1("Startup of logical replication to node %d", MtmReplicationNodeId);
36333634
MtmLock(LW_EXCLUSIVE);
36343635

3636+
/*
3637+
* Set proper originId mappings.
3638+
*
3639+
* This is copypasted from receiver. Better to have normal init method
3640+
* to setup all stuff in shared memory. But seems that there is no such
3641+
* callback in vanilla pg and adding one will require some carefull thoughts.
3642+
*/
3643+
for (i = 0; i < Mtm->nAllNodes; i++)
3644+
{
3645+
char *originName;
3646+
RepOriginId originId;
3647+
3648+
originName = psprintf(MULTIMASTER_SLOT_PATTERN, i + 1);
3649+
originId = replorigin_by_name(originName, true);
3650+
if (originId == InvalidRepOriginId) {
3651+
originId = replorigin_create(originName);
3652+
}
3653+
CommitTransactionCommand();
3654+
StartTransactionCommand();
3655+
Mtm->nodes[i].originId = originId;
3656+
}
3657+
36353658
if (BIT_CHECK(Mtm->stalledNodeMask, MtmReplicationNodeId-1)) {
36363659
MtmUnlock();
36373660
MTM_ELOG(ERROR, "Stalled node %d tries to initiate recovery", MtmReplicationNodeId);

0 commit comments

Comments
 (0)