mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: atomically remove partitions, which went outside the configured retention
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3038
This commit is contained in:
parent
978dcb4574
commit
340ada871d
3 changed files with 5 additions and 2 deletions
|
@ -211,6 +211,7 @@ func MustRemoveDirAtomic(dir string) {
|
|||
if err := os.Rename(dir, tmpDir); err != nil {
|
||||
logger.Panicf("FATAL: cannot move %s to %s: %s", dir, tmpDir, err)
|
||||
}
|
||||
MustSyncPath(dir)
|
||||
MustRemoveAll(tmpDir)
|
||||
}
|
||||
|
||||
|
|
|
@ -236,8 +236,8 @@ func (pt *partition) Drop() {
|
|||
// Wait until all the pending transaction deletions are finished before removing partition directories.
|
||||
pendingTxnDeletionsWG.Wait()
|
||||
|
||||
fs.MustRemoveAll(pt.smallPartsPath)
|
||||
fs.MustRemoveAll(pt.bigPartsPath)
|
||||
fs.MustRemoveDirAtomic(pt.smallPartsPath)
|
||||
fs.MustRemoveDirAtomic(pt.bigPartsPath)
|
||||
logger.Infof("partition %q has been dropped", pt.name)
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ func openTable(path string, getDeletedMetricIDs func() *uint64set.Set, retention
|
|||
if err := fs.MkdirAllIfNotExist(smallPartitionsPath); err != nil {
|
||||
return nil, fmt.Errorf("cannot create directory for small partitions %q: %w", smallPartitionsPath, err)
|
||||
}
|
||||
fs.MustRemoveTemporaryDirs(smallPartitionsPath)
|
||||
smallSnapshotsPath := smallPartitionsPath + "/snapshots"
|
||||
if err := fs.MkdirAllIfNotExist(smallSnapshotsPath); err != nil {
|
||||
return nil, fmt.Errorf("cannot create %q: %w", smallSnapshotsPath, err)
|
||||
|
@ -113,6 +114,7 @@ func openTable(path string, getDeletedMetricIDs func() *uint64set.Set, retention
|
|||
if err := fs.MkdirAllIfNotExist(bigPartitionsPath); err != nil {
|
||||
return nil, fmt.Errorf("cannot create directory for big partitions %q: %w", bigPartitionsPath, err)
|
||||
}
|
||||
fs.MustRemoveTemporaryDirs(bigPartitionsPath)
|
||||
bigSnapshotsPath := bigPartitionsPath + "/snapshots"
|
||||
if err := fs.MkdirAllIfNotExist(bigSnapshotsPath); err != nil {
|
||||
return nil, fmt.Errorf("cannot create %q: %w", bigSnapshotsPath, err)
|
||||
|
|
Loading…
Reference in a new issue