mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
This commit is contained in:
parent
bfe96a3cb4
commit
0fbf59199a
1 changed files with 5 additions and 1 deletions
|
@ -1038,12 +1038,16 @@ var saveCacheLock sync.Mutex
|
|||
func nextRetentionDuration(retentionMsecs int64) time.Duration {
|
||||
// Round retentionMsecs to days. This guarantees that per-day inverted index works as expected.
|
||||
retentionMsecs = ((retentionMsecs + msecPerDay - 1) / msecPerDay) * msecPerDay
|
||||
t := time.Now().UnixNano() / 1e6
|
||||
now := time.Now()
|
||||
t := now.UnixNano() / 1e6
|
||||
deadline := ((t + retentionMsecs - 1) / retentionMsecs) * retentionMsecs
|
||||
// Schedule the deadline to +4 hours from the next retention period start.
|
||||
// This should prevent from possible double deletion of indexdb
|
||||
// due to time drift - see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/248 .
|
||||
deadline += 4 * 3600 * 1000
|
||||
// The effect of time zone on retention period is moved out
|
||||
_, offset := now.Zone()
|
||||
deadline -= int64(offset) * 1000
|
||||
return time.Duration(deadline-t) * time.Millisecond
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue