diff options
Diffstat (limited to 'src/backend/access/transam/xlogrecovery.c')
-rw-r--r-- | src/backend/access/transam/xlogrecovery.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index dbe93947627..02d1b2cd6d8 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -1935,6 +1935,31 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl XLogRecoveryCtl->lastReplayedTLI = *replayTLI; SpinLockRelease(&XLogRecoveryCtl->info_lck); + /* ------ + * Wakeup walsenders: + * + * On the standby, the WAL is flushed first (which will only wake up + * physical walsenders) and then applied, which will only wake up logical + * walsenders. + * + * Indeed, logical walsenders on standby can't decode and send data until + * it's been applied. + * + * Physical walsenders don't need to be woken up during replay unless + * cascading replication is allowed and time line change occurred (so that + * they can notice that they are on a new time line). + * + * That's why the wake up conditions are for: + * + * - physical walsenders in case of new time line and cascade + * replication is allowed + * - logical walsenders in case cascade replication is allowed (could not + * be created otherwise) + * ------ + */ + if (AllowCascadeReplication()) + WalSndWakeup(switchedTLI, true); + /* * If rm_redo called XLogRequestWalReceiverReply, then we wake up the * receiver so that it notices the updated lastReplayedEndRecPtr and sends @@ -1958,12 +1983,6 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl */ RemoveNonParentXlogFiles(xlogreader->EndRecPtr, *replayTLI); - /* - * Wake up any walsenders to notice that we are on a new timeline. - */ - if (AllowCascadeReplication()) - WalSndWakeup(); - /* Reset the prefetcher. */ XLogPrefetchReconfigure(); } @@ -3050,9 +3069,9 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode, { /* * When we find that WAL ends in an incomplete record, keep track - * of that record. After recovery is done, we'll write a record to - * indicate to downstream WAL readers that that portion is to be - * ignored. + * of that record. After recovery is done, we'll write a record + * to indicate to downstream WAL readers that that portion is to + * be ignored. * * However, when ArchiveRecoveryRequested = true, we're going to * switch to a new timeline at the end of recovery. We will only |