diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c index 48e8498d62..5066688288 100644 --- a/src/backend/replication/walreceiverfuncs.c +++ b/src/backend/replication/walreceiverfuncs.c @@ -280,7 +280,26 @@ RequestXLogStreaming(TimeLineID tli, XLogRecPtr recptr, const char *conninfo, SpinLockRelease(&walrcv->mutex); if (launch) + { SendPostmasterSignal(PMSIGNAL_START_WALRECEIVER); + + for(;;) + { + /* + * Now we want to restart walreciver process and walrcv->walRcvState is WALRCV_STARTING. + * We should not go on startup process until walrcv->walRcvState changed to other value. + * + * And we do a loop here in case of there may be any delay during restart of walreciver process. + */ + if(WALRCV_STARTING != walrcv->walRcvState) + { + break; + } + + elog(LOG,"startup process is waiting for restart of walreciver process"); + pg_usleep(1000000L); + } + } else if (latch) SetLatch(latch); }