diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index ed3ef55ebe7..bff667f577b 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -175,6 +175,7 @@ WalReceiverMain(void) /* use volatile pointer to prevent code rearrangement */ volatile WalRcvData *walrcv = WalRcv; + TimestampTz now; /* * WalRcv should be set up already (if we are a backend, we inherit this @@ -182,6 +183,8 @@ WalReceiverMain(void) */ Assert(walrcv != NULL); + now = GetCurrentTimestamp(); + /* * Mark walreceiver as running in shared memory. * @@ -209,6 +212,7 @@ WalReceiverMain(void) case WALRCV_RUNNING: /* Shouldn't happen */ + SpinLockRelease(&walrcv->mutex); elog(PANIC, "walreceiver still running according to shared memory state"); } /* Advertise our PID so that the startup process can kill us */ @@ -220,7 +224,8 @@ WalReceiverMain(void) startpoint = walrcv->receiveStart; /* Initialise to a sanish value */ - walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = GetCurrentTimestamp(); + walrcv->lastMsgSendTime = + walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = now; SpinLockRelease(&walrcv->mutex);