mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-05 22:32:20 +01:00
vmstorage: switch to rich duration parser for flag snapshotsMaxAge
(#2542)
The switch suppose to allow setting `d`, `w`, `y` duration units. Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
c5e47929c3
commit
c41ae2db2c
@ -32,7 +32,7 @@ var (
|
|||||||
snapshotAuthKey = flag.String("snapshotAuthKey", "", "authKey, which must be passed in query string to /snapshot* pages")
|
snapshotAuthKey = flag.String("snapshotAuthKey", "", "authKey, which must be passed in query string to /snapshot* pages")
|
||||||
forceMergeAuthKey = flag.String("forceMergeAuthKey", "", "authKey, which must be passed in query string to /internal/force_merge pages")
|
forceMergeAuthKey = flag.String("forceMergeAuthKey", "", "authKey, which must be passed in query string to /internal/force_merge pages")
|
||||||
forceFlushAuthKey = flag.String("forceFlushAuthKey", "", "authKey, which must be passed in query string to /internal/force_flush pages")
|
forceFlushAuthKey = flag.String("forceFlushAuthKey", "", "authKey, which must be passed in query string to /internal/force_flush pages")
|
||||||
snapshotsMaxAge = flag.Duration("snapshotsMaxAge", 0, "Automatically delete snapshots older than -snapshotsMaxAge if it is set to non-zero duration. Make sure that backup process has enough time to finish the backup before the corresponding snapshot is automatically deleted")
|
snapshotsMaxAge = flagutil.NewDuration("snapshotsMaxAge", "0", "Automatically delete snapshots older than -snapshotsMaxAge if it is set to non-zero duration. Make sure that backup process has enough time to finish the backup before the corresponding snapshot is automatically deleted")
|
||||||
|
|
||||||
finalMergeDelay = flag.Duration("finalMergeDelay", 0, "The delay before starting final merge for per-month partition after no new data is ingested into it. "+
|
finalMergeDelay = flag.Duration("finalMergeDelay", 0, "The delay before starting final merge for per-month partition after no new data is ingested into it. "+
|
||||||
"Final merge may require additional disk IO and CPU resources. Final merge may increase query speed and reduce disk space usage in some cases. "+
|
"Final merge may require additional disk IO and CPU resources. Final merge may increase query speed and reduce disk space usage in some cases. "+
|
||||||
@ -253,9 +253,10 @@ func requestHandler(w http.ResponseWriter, r *http.Request, strg *storage.Storag
|
|||||||
|
|
||||||
func initStaleSnapshotsRemover(strg *storage.Storage) {
|
func initStaleSnapshotsRemover(strg *storage.Storage) {
|
||||||
staleSnapshotsRemoverCh = make(chan struct{})
|
staleSnapshotsRemoverCh = make(chan struct{})
|
||||||
if *snapshotsMaxAge <= 0 {
|
if snapshotsMaxAge.Msecs <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
snapshotsMaxAgeDur := time.Duration(snapshotsMaxAge.Msecs) * time.Millisecond
|
||||||
staleSnapshotsRemoverWG.Add(1)
|
staleSnapshotsRemoverWG.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer staleSnapshotsRemoverWG.Done()
|
defer staleSnapshotsRemoverWG.Done()
|
||||||
@ -267,7 +268,7 @@ func initStaleSnapshotsRemover(strg *storage.Storage) {
|
|||||||
return
|
return
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
}
|
}
|
||||||
if err := strg.DeleteStaleSnapshots(*snapshotsMaxAge); err != nil {
|
if err := strg.DeleteStaleSnapshots(snapshotsMaxAgeDur); err != nil {
|
||||||
// Use logger.Errorf instead of logger.Fatalf in the hope the error is temporary.
|
// Use logger.Errorf instead of logger.Fatalf in the hope the error is temporary.
|
||||||
logger.Errorf("cannot delete stale snapshots: %s", err)
|
logger.Errorf("cannot delete stale snapshots: %s", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user