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

Commit 16be973

Browse files
committed
Don't delay replication for less than recovery_min_apply_delay's resolution.
Recovery delays are implemented by waiting on a latch, and latches take milliseconds as a parameter. The required amount of waiting was computed using microsecond resolution though and the wait loop's abort condition was checking the delay in microseconds as well. This could lead to short spurts of busy looping when the overall wait time was below a millisecond, but above 0 microseconds. Instead just formulate the wait loop's abort condition in millisecond granularity as well. Given that that's recovery_min_apply_delay resolution, it seems harmless to not wait for less than a millisecond. Backpatch to 9.4 where recovery_min_apply_delay was introduced. Discussion: 20150323141819.GH26995@alap3.anarazel.de
1 parent 76d07a2 commit 16be973

File tree

1 file changed

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

1 file changed

+2
-1
lines changed

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5802,7 +5802,8 @@ recoveryApplyDelay(XLogRecord *record)
58025802
TimestampDifference(GetCurrentTimestamp(), recoveryDelayUntilTime,
58035803
&secs, &microsecs);
58045804

5805-
if (secs <= 0 && microsecs <= 0)
5805+
/* NB: We're ignoring waits below min_apply_delay's resolution. */
5806+
if (secs <= 0 && microsecs / 1000 <= 0)
58065807
break;
58075808

58085809
elog(DEBUG2, "recovery apply delay %ld seconds, %d milliseconds",

0 commit comments

Comments
 (0)