aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2015-03-23 16:40:10 +0100
committerAndres Freund <andres@anarazel.de>2015-03-23 16:52:17 +0100
commit16be9737cc3d5f7da599a5c2fe2ff975db296f3b (patch)
tree0bb26604a9a28fd4013c4976fc9f2e884a237230 /src/backend/access/transam/xlog.c
parent76d07a2a0633836a82c43beb8ed3b08a64dc3d46 (diff)
downloadpostgresql-16be9737cc3d5f7da599a5c2fe2ff975db296f3b.tar.gz
postgresql-16be9737cc3d5f7da599a5c2fe2ff975db296f3b.zip
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
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index c75e9c09de5..7cf29b69ea5 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -5802,7 +5802,8 @@ recoveryApplyDelay(XLogRecord *record)
TimestampDifference(GetCurrentTimestamp(), recoveryDelayUntilTime,
&secs, &microsecs);
- if (secs <= 0 && microsecs <= 0)
+ /* NB: We're ignoring waits below min_apply_delay's resolution. */
+ if (secs <= 0 && microsecs / 1000 <= 0)
break;
elog(DEBUG2, "recovery apply delay %ld seconds, %d milliseconds",