Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Tor Tor
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 325
    • Issues 325
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 30
    • Merge requests 30
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • The Tor Project
  • Core
  • TorTor
  • Issues
  • #40394
Closed
Open
Issue created May 16, 2021 by Roger Dingledine@armaReporter

Fencepost error in checking stability_last_downrated results in double calls to rep_hist_downrate_old_runs()

Check out this code in rep_hist_downrate_old_runs() in src/feature/stats/rephist.c:

  if (stability_last_downrated + STABILITY_INTERVAL > now)
    return stability_last_downrated + STABILITY_INTERVAL;

  /* Okay, we should downrate the data.  By how much? */
  while (stability_last_downrated + STABILITY_INTERVAL < now) {
    stability_last_downrated += STABILITY_INTERVAL;
    alpha *= STABILITY_ALPHA;
  }
[...]
 return stability_last_downrated + STABILITY_INTERVAL;

Ok, so we tell it to call the function next when now == stability_last_downrated + STABILITY_INTERVAL. But the first check above is >, and the second check is <.

This results in double-calls each 12 hour period, where the first call uses an alpha of 1.0:

May 15 23:48:13.752 [info] rep_hist_downrate_old_runs(): Discounting all old stability info by a factor of 1.000000
May 15 23:48:14.752 [info] rep_hist_downrate_old_runs(): Discounting all old stability info by a factor of 0.950000
May 16 11:48:13.753 [info] rep_hist_downrate_old_runs(): Discounting all old stability info by a factor of 1.000000
May 16 11:48:14.752 [info] rep_hist_downrate_old_runs(): Discounting all old stability info by a factor of 0.950000

As far as I can tell, the call with alpha at 1.0 is harmless? I think?

And I guess that the fix is to turn the < into a <=.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking