diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index 0158ae06826..5f181d118da 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -195,6 +195,7 @@ WalReceiverMain(void) /* use volatile pointer to prevent code rearrangement */ volatile WalRcvData *walrcv = WalRcv; TimestampTz last_recv_timestamp; + TimestampTz now; bool ping_sent; /* @@ -203,6 +204,8 @@ WalReceiverMain(void) */ Assert(walrcv != NULL); + now = GetCurrentTimestamp(); + /* * Mark walreceiver as running in shared memory. * @@ -233,6 +236,7 @@ WalReceiverMain(void) case WALRCV_RESTARTING: default: /* 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 */ @@ -245,7 +249,8 @@ WalReceiverMain(void) startpointTLI = walrcv->receiveStartTLI; /* Initialise to a sanish value */ - walrcv->lastMsgSendTime = walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = GetCurrentTimestamp(); + walrcv->lastMsgSendTime = + walrcv->lastMsgReceiptTime = walrcv->latestWalEndTime = now; SpinLockRelease(&walrcv->mutex);