You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The random delay before an available update is added as milliseconds, not seconds #72
When a data file says when its next update is available, the data update service schedules the next check for that time plus a random delay. The random delay is meant to be up to MaxRandomisationSeconds seconds, so that many servers do not all ask for the update at once. On this path it is added as milliseconds. With the default of 600 seconds (DATA_UPDATE_RANDOMISATION_DEFAULT in Constants.java line 29), the checks spread over 0.6 seconds instead of 10 minutes.
applyIntervalRandomisation(interval, config) adds random.nextInt(config.getMaxRandomisationSeconds()) to interval as it stands, whatever unit interval is in (lines 574 to 580).
getInterval passes seconds and multiplies the result by 1000 (lines 557 to 564), so the polling interval's random delay is in seconds, as intended.
registerDataFile passes the milliseconds until the update is available, getUpdateAvailableTime().getTime() - System.currentTimeMillis(), and uses the result as milliseconds (lines 424 to 431). The random seconds are therefore added as milliseconds.
Fix
Convert the random delay to milliseconds on that path, for example by giving applyIntervalRandomisation a millisecond interval and returning milliseconds in both callers, with a test that the delay on the update-available path can exceed one second.
Related
Found while fixing #70 in #71, which leaves this unchanged.
Whether .NET has the same mismatch has not been checked.
Activity