Skip to content

Commit 84c1bac

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 cdda2b2 commit 84c1bac

File tree

1 file changed

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

1 file changed

+11
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6053,12 +6053,22 @@ recoveryApplyDelay(XLogReaderState *record)
60536053
{
60546054
ResetLatch(&XLogCtl->recoveryWakeupLatch);
60556055

6056-
/* might change the trigger file's location */
6056+
/*
6057+
* This might change recovery_min_apply_delay or the trigger file's
6058+
* location.
6059+
*/
60576060
HandleStartupProcInterrupts();
60586061

60596062
if (CheckForStandbyTrigger())
60606063
break;
60616064

6065+
/*
6066+
* Recalculate recoveryDelayUntilTime as recovery_min_apply_delay
6067+
* could have changed while waiting in this loop.
6068+
*/
6069+
recoveryDelayUntilTime =
6070+
TimestampTzPlusMilliseconds(xtime, recovery_min_apply_delay);
6071+
60626072
/*
60636073
* Wait for difference between GetCurrentTimestamp() and
60646074
* recoveryDelayUntilTime

0 commit comments

Comments
 (0)