mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Change pg_last_xlog_receive_location() not to move backwards. That makes
it a lot more useful for determining which standby is most up-to-date, for example. There was long discussions on whether overwriting existing existing WAL makes sense to begin with, and whether we should do some more extensive variable renaming, but this change nevertheless seems quite uncontroversial. Fujii Masao, reviewed by Jeff Janes, Robert Haas, Stephen Frost.
This commit is contained in:
@ -218,7 +218,7 @@ WalReceiverMain(void)
|
||||
|
||||
/* Fetch information required to start streaming */
|
||||
strlcpy(conninfo, (char *) walrcv->conninfo, MAXCONNINFO);
|
||||
startpoint = walrcv->receivedUpto;
|
||||
startpoint = walrcv->receiveStart;
|
||||
SpinLockRelease(&walrcv->mutex);
|
||||
|
||||
/* Arrange to clean up at walreceiver exit */
|
||||
@ -558,8 +558,11 @@ XLogWalRcvFlush(bool dying)
|
||||
|
||||
/* Update shared-memory status */
|
||||
SpinLockAcquire(&walrcv->mutex);
|
||||
walrcv->latestChunkStart = walrcv->receivedUpto;
|
||||
walrcv->receivedUpto = LogstreamResult.Flush;
|
||||
if (XLByteLT(walrcv->receivedUpto, LogstreamResult.Flush))
|
||||
{
|
||||
walrcv->latestChunkStart = walrcv->receivedUpto;
|
||||
walrcv->receivedUpto = LogstreamResult.Flush;
|
||||
}
|
||||
SpinLockRelease(&walrcv->mutex);
|
||||
|
||||
/* Signal the startup process that new WAL has arrived */
|
||||
|
@ -199,8 +199,17 @@ RequestXLogStreaming(XLogRecPtr recptr, const char *conninfo)
|
||||
walrcv->walRcvState = WALRCV_STARTING;
|
||||
walrcv->startTime = now;
|
||||
|
||||
walrcv->receivedUpto = recptr;
|
||||
walrcv->latestChunkStart = recptr;
|
||||
/*
|
||||
* If this is the first startup of walreceiver, we initialize
|
||||
* receivedUpto and latestChunkStart to receiveStart.
|
||||
*/
|
||||
if (walrcv->receiveStart.xlogid == 0 &&
|
||||
walrcv->receiveStart.xrecoff == 0)
|
||||
{
|
||||
walrcv->receivedUpto = recptr;
|
||||
walrcv->latestChunkStart = recptr;
|
||||
}
|
||||
walrcv->receiveStart = recptr;
|
||||
|
||||
SpinLockRelease(&walrcv->mutex);
|
||||
|
||||
|
Reference in New Issue
Block a user