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 <=.