@@ -3587,6 +3587,7 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
3587
3587
ListCell * param ;
3588
3588
bool recoveryCompleted = false;
3589
3589
ulong64 recoveryStartPos = INVALID_LSN ;
3590
+ int i ;
3590
3591
3591
3592
MtmIsRecoverySession = false;
3592
3593
Mtm -> nodes [MtmReplicationNodeId - 1 ].senderPid = MyProcPid ;
@@ -3632,6 +3633,28 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
3632
3633
MTM_LOG1 ("Startup of logical replication to node %d" , MtmReplicationNodeId );
3633
3634
MtmLock (LW_EXCLUSIVE );
3634
3635
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
+
3635
3658
if (BIT_CHECK (Mtm -> stalledNodeMask , MtmReplicationNodeId - 1 )) {
3636
3659
MtmUnlock ();
3637
3660
MTM_ELOG (ERROR , "Stalled node %d tries to initiate recovery" , MtmReplicationNodeId );
0 commit comments