Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e4ba100

Browse files
committed
Refresh apply delay on reload of recovery_min_apply_delay at recovery
This commit ensures that the wait interval in the replay delay loop waiting for an amount of time defined by recovery_min_apply_delay is correctly handled on reload, recalculating the delay if this GUC value is updated, based on the timestamp of the commit record being replayed. The previous behavior would be problematic for example with replay still waiting even if the delay got reduced or just cancelled. If the apply delay was increased to a larger value, the wait would have just respected the old value set, finishing earlier. Author: Soumyadeep Chakraborty, Ashwin Agrawal Reviewed-by: Kyotaro Horiguchi, Michael Paquier Discussion: https://postgr.es/m/CAE-ML+93zfr-HLN8OuxF0BjpWJ17O5dv1eMvSE5jsj9jpnAXZA@mail.gmail.com Backpatch-through: 9.6
1 parent 0a208ed commit e4ba100

File tree

1 file changed

+11
-2
lines changed
  • src/backend/access/transam

1 file changed

+11
-2
lines changed

src/backend/access/transam/xlog.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -6248,14 +6248,23 @@ recoveryApplyDelay(XLogReaderState *record)
62486248
{
62496249
ResetLatch(&XLogCtl->recoveryWakeupLatch);
62506250

6251-
/* might change the trigger file's location */
6251+
/*
6252+
* This might change recovery_min_apply_delay or the trigger file's
6253+
* location.
6254+
*/
62526255
HandleStartupProcInterrupts();
62536256

62546257
if (CheckForStandbyTrigger())
62556258
break;
62566259

62576260
/*
6258-
* Wait for difference between GetCurrentTimestamp() and delayUntil
6261+
* Recalculate delayUntil as recovery_min_apply_delay could have
6262+
* changed while waiting in this loop.
6263+
*/
6264+
delayUntil = TimestampTzPlusMilliseconds(xtime, recovery_min_apply_delay);
6265+
6266+
/*
6267+
* Wait for difference between GetCurrentTimestamp() and delayUntil.
62596268
*/
62606269
msecs = TimestampDifferenceMilliseconds(GetCurrentTimestamp(),
62616270
delayUntil);

0 commit comments

Comments
 (0)