mirror of https://github.com/prometheus/prometheus
Merge pull request #12664 from prometheus/superq/cleanup_chunk_snapshots
Cleanup temporary chunk snapshot dirspull/12676/head
commit
e3fabd5fdf
|
@ -2092,7 +2092,8 @@ func isBlockDir(fi fs.DirEntry) bool {
|
|||
return err == nil
|
||||
}
|
||||
|
||||
// isTmpDir returns true if the given file-info contains a block ULID or checkpoint prefix and a tmp extension.
|
||||
// isTmpDir returns true if the given file-info contains a block ULID, a checkpoint prefix,
|
||||
// or a chunk snapshot prefix and a tmp extension.
|
||||
func isTmpDir(fi fs.DirEntry) bool {
|
||||
if !fi.IsDir() {
|
||||
return false
|
||||
|
@ -2104,6 +2105,9 @@ func isTmpDir(fi fs.DirEntry) bool {
|
|||
if strings.HasPrefix(fn, "checkpoint.") {
|
||||
return true
|
||||
}
|
||||
if strings.HasPrefix(fn, chunkSnapshotPrefix) {
|
||||
return true
|
||||
}
|
||||
if _, err := ulid.ParseStrict(fn[:len(fn)-len(ext)]); err == nil {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -3147,6 +3147,9 @@ func TestOpen_VariousBlockStates(t *testing.T) {
|
|||
tmpCheckpointDir := path.Join(tmpDir, "wal/checkpoint.00000001.tmp")
|
||||
err := os.MkdirAll(tmpCheckpointDir, 0o777)
|
||||
require.NoError(t, err)
|
||||
tmpChunkSnapshotDir := path.Join(tmpDir, chunkSnapshotPrefix+"0000.00000001.tmp")
|
||||
err = os.MkdirAll(tmpChunkSnapshotDir, 0o777)
|
||||
require.NoError(t, err)
|
||||
|
||||
opts := DefaultOptions()
|
||||
opts.RetentionDuration = 0
|
||||
|
@ -3180,6 +3183,8 @@ func TestOpen_VariousBlockStates(t *testing.T) {
|
|||
require.Equal(t, len(expectedIgnoredDirs), ignored)
|
||||
_, err = os.Stat(tmpCheckpointDir)
|
||||
require.True(t, os.IsNotExist(err))
|
||||
_, err = os.Stat(tmpChunkSnapshotDir)
|
||||
require.True(t, os.IsNotExist(err))
|
||||
}
|
||||
|
||||
func TestOneCheckpointPerCompactCall(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue