Skip to content

The random delay before an available update is added as milliseconds, not seconds #72

Open

Description

@jwrosewell

Problem

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.

What the code does

Line numbers are for rc at 22995070.

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions