Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F160353933
D10211.id26894.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D10211.id26894.diff
View Options
Index: etc/defaults/periodic.conf
===================================================================
--- etc/defaults/periodic.conf
+++ etc/defaults/periodic.conf
@@ -22,6 +22,8 @@
# periodic script dirs
local_periodic="/usr/local/etc/periodic"
+# Max time to sleep to avoid causing congestion on download servers
+anticongestion_sleeptime=3600
# Daily options
@@ -136,8 +138,6 @@
# 480.leapfile-ntpd
daily_ntpd_leapfile_enable="YES" # Fetch NTP leapfile
-daily_ntpd_avoid_congestion="YES" # Avoid congesting
- # leapfile sources
# 480.status-ntpd
daily_status_ntpd_enable="NO" # Check NTP status
@@ -307,6 +307,18 @@
if [ -z "${source_periodic_confs_defined}" ]; then
source_periodic_confs_defined=yes
+ # Sleep for a random amount of time in order to mitigate the thundering
+ # herd problem of multiple hosts running periodic simultaneously.
+ # Will not sleep when used interactively.
+ # Will sleep at most once per invocation of periodic
+ anticongestion() {
+ [ -n "$PERIODIC_IS_INTERACTIVE" ] && return
+ if [ -f "$PERIODIC_ANTICONGESTION_FILE" ]; then
+ rm -f $PERIODIC_ANTICONGESTION_FILE
+ sleep `jot -r 1 0 ${anticongestion_sleeptime}`
+ fi
+ }
+
# Compatibility with old daily variable names.
# They can be removed in stable/11.
security_daily_compat_var() {
Index: etc/periodic/daily/480.leapfile-ntpd
===================================================================
--- etc/periodic/daily/480.leapfile-ntpd
+++ etc/periodic/daily/480.leapfile-ntpd
@@ -13,16 +13,9 @@
case "$daily_ntpd_leapfile_enable" in
[Yy][Ee][Ss])
- case "$daily_ntpd_avoid_congestion" in
- [Yy][Ee][Ss])
- # Avoid dogpiling
- (sleep $(jot -r 1 0 3600); service ntpd onefetch) &
- ;;
- *)
- service ntpd onefetch
- ;;
- esac
- ;;
+ anticongestion
+ service ntpd onefetch
+ ;;
esac
exit $rc
Index: usr.sbin/periodic/periodic.sh
===================================================================
--- usr.sbin/periodic/periodic.sh
+++ usr.sbin/periodic/periodic.sh
@@ -76,6 +76,12 @@
shift
arg=$1
+if [ -z "$PERIODIC_ANTICONGESTION_FILE" ] ; then
+ export PERIODIC_ANTICONGESTION_FILE=`mktemp ${TMPDIR:-/tmp}/periodic.anticongestion.XXXXXXXXXX`
+fi
+if tty > /dev/null 2>&1; then
+ export PERIODIC_IS_INTERACTIVE=1
+fi
tmp_output=`mktemp ${TMPDIR:-/tmp}/periodic.XXXXXXXXXX`
context="$PERIODIC"
export PERIODIC="$arg${PERIODIC:+ }${PERIODIC}"
@@ -141,3 +147,4 @@
} | output_pipe $arg "$context"
rm -f $tmp_output
+rm -f $PERIODIC_ANTICONGESTION_FILE
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 24, 2:59 PM (8 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34286457
Default Alt Text
D10211.id26894.diff (2 KB)
Attached To
Mode
D10211: Consolidate random sleeps in periodic scripts
Attached
Detach File
Event Timeline
Log In to Comment