@@ -3648,9 +3648,6 @@ MtmBgwStart(MtmBgw *bgw)
36483648bgw -> name ),
36493649errhint ("You may need to increase max_worker_processes." )));
36503650
3651- status = WaitForBackgroundWorkerStartup (bgw -> handle ,& pid );
3652- if (status != BGWH_STARTED )
3653- mtm_log (ERROR ,"failed to start background process %s" ,bgw -> name );
36543651bgw -> last_start_time = GetCurrentTimestamp ();
36553652}
36563653
@@ -3749,12 +3746,19 @@ start_node_workers(int node_id, MtmConfig *new_cfg, Datum arg)
37493746 * Create filter slot to filter out already applied changes since the
37503747 * last syncpoint during replication start
37513748 */
3752- ReplicationSlotCreate (filter_slot , false,RS_PERSISTENT );
3753- ReplicationSlotReserveWal ();
3754- /* Write this slot to disk */
3755- ReplicationSlotMarkDirty ();
3756- ReplicationSlotSave ();
3757- ReplicationSlotRelease ();
3749+ /* slot might be already created if we failed before setting init_done */
3750+ int acq = ReplicationSlotAcquire (filter_slot ,SAB_Inquire );
3751+ if (acq == 0 )
3752+ ReplicationSlotRelease ();
3753+ else if (acq == -1 )
3754+ {
3755+ ReplicationSlotCreate (filter_slot , false,RS_PERSISTENT );
3756+ ReplicationSlotReserveWal ();
3757+ /* Write this slot to disk */
3758+ ReplicationSlotMarkDirty ();
3759+ ReplicationSlotSave ();
3760+ ReplicationSlotRelease ();
3761+ }
37583762}
37593763
37603764/* Add dmq destination */
@@ -3789,18 +3793,25 @@ start_node_workers(int node_id, MtmConfig *new_cfg, Datum arg)
37893793int rc ;
37903794
37913795/* Create logical slot for our publication to this neighbour */
3792- ReplicationSlotCreate (slot , true,RS_EPHEMERAL );
3793- ctx = CreateInitDecodingContext (MULTIMASTER_NAME ,NIL ,
3794- false,/* do not build snapshot */
3795- InvalidXLogRecPtr ,
3796- XL_ROUTINE (.page_read = read_local_xlog_page ,
3797- .segment_open = wal_segment_open ,
3798- .segment_close = wal_segment_close ),
3799- NULL ,NULL ,NULL );
3800- DecodingContextFindStartpoint (ctx );
3801- FreeDecodingContext (ctx );
3802- ReplicationSlotPersist ();
3803- ReplicationSlotRelease ();
3796+ /* slot might be already created if we failed before setting init_done */
3797+ int acq = ReplicationSlotAcquire (slot ,SAB_Inquire );
3798+ if (acq == 0 )
3799+ ReplicationSlotRelease ();
3800+ else if (acq == -1 )
3801+ {
3802+ ReplicationSlotCreate (slot , true,RS_EPHEMERAL );
3803+ ctx = CreateInitDecodingContext (MULTIMASTER_NAME ,NIL ,
3804+ false,/* do not build snapshot */
3805+ InvalidXLogRecPtr ,
3806+ XL_ROUTINE (.page_read = read_local_xlog_page ,
3807+ .segment_open = wal_segment_open ,
3808+ .segment_close = wal_segment_close ),
3809+ NULL ,NULL ,NULL );
3810+ DecodingContextFindStartpoint (ctx );
3811+ FreeDecodingContext (ctx );
3812+ ReplicationSlotPersist ();
3813+ ReplicationSlotRelease ();
3814+ }
38043815
38053816/*
38063817 * Mark this node as init_done, so at next boot we won't try to create