fix(purge): short first tick on all three purge timers so daily-recycled nodes still purge

This commit is contained in:
Joseph Doherty
2026-07-09 09:26:42 -04:00
parent 7cd62933a6
commit b58d810dbe
5 changed files with 89 additions and 5 deletions
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging;
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Kpi;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Kpi;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
using ZB.MOM.WW.ScadaBridge.Commons.Types;
namespace ZB.MOM.WW.ScadaBridge.KpiHistory;
@@ -119,12 +120,15 @@ public class KpiHistoryRecorderActor : ReceiveActor, IWithTimers
initialDelay: TimeSpan.FromSeconds(5),
interval: _options.SampleInterval);
// The purge is daily and idempotent — no initial fast tick; the first sweep
// fires after a full PurgeInterval.
// The purge is idempotent, so it takes a short first tick (min(PurgeInterval, 5min)):
// scheduling the first sweep a full PurgeInterval out meant a node recycled more often
// than the interval (e.g. daily restart vs. daily cadence) would never purge
// (arch-review 04, S9). Fast test cadences (interval < 5min) are unchanged.
Timers.StartPeriodicTimer(
PurgeTimerKey,
PurgeTick.Instance,
_options.PurgeInterval);
initialDelay: PurgeTimerSchedule.InitialDelay(_options.PurgeInterval),
interval: _options.PurgeInterval);
}
/// <inheritdoc />