fix: checkpoint initialization gap on restarts

Entire-Checkpoint: 3f4d366b037c
This commit is contained in:
2026-03-27 06:59:58 +01:00
parent 71fc9efec7
commit 0ce2fa2fbe
3 changed files with 33 additions and 11 deletions

View File

@@ -53,6 +53,16 @@ func cleanUpWorker(wg *sync.WaitGroup, ctx context.Context, interval string, mod
return
}
// Account for checkpoint span: files named {from}.bin contain data up to
// from+checkpointInterval. Subtract the checkpoint interval so we don't
// delete files whose data still falls within the retention window.
checkpointSpan := 12 * time.Hour
if Keys.CheckpointInterval != "" {
if parsed, err := time.ParseDuration(Keys.CheckpointInterval); err == nil {
checkpointSpan = parsed
}
}
ticker := time.NewTicker(d)
defer ticker.Stop()
@@ -61,7 +71,7 @@ func cleanUpWorker(wg *sync.WaitGroup, ctx context.Context, interval string, mod
case <-ctx.Done():
return
case <-ticker.C:
t := time.Now().Add(-d)
t := time.Now().Add(-d).Add(-checkpointSpan)
cclog.Infof("[METRICSTORE]> start %s checkpoints (older than %s)...", mode, t.Format(time.RFC3339))
n, err := CleanupCheckpoints(Keys.Checkpoints.RootDir, cleanupDir, t.Unix(), delete)