mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
fix: remove pre-2.21 tmp blocks on start (#8353)
* fix: remove pre-2.21 tmp blocks on start Signed-off-by: Nguyen Le Vu Long <vulongvn98@gmail.com> * fix: commenting Signed-off-by: Nguyen Le Vu Long <vulongvn98@gmail.com>
This commit is contained in:
parent
fd022965c0
commit
fbe960f2c1
@ -56,6 +56,8 @@ const (
|
||||
// about removing those too on start to save space. Currently only blocks tmp dirs are removed.
|
||||
tmpForDeletionBlockDirSuffix = ".tmp-for-deletion"
|
||||
tmpForCreationBlockDirSuffix = ".tmp-for-creation"
|
||||
// Pre-2.21 tmp dir suffix, used in clean-up functions.
|
||||
tmpLegacy = ".tmp"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -1570,7 +1572,7 @@ func isTmpBlockDir(fi os.FileInfo) bool {
|
||||
|
||||
fn := fi.Name()
|
||||
ext := filepath.Ext(fn)
|
||||
if ext == tmpForDeletionBlockDirSuffix || ext == tmpForCreationBlockDirSuffix {
|
||||
if ext == tmpForDeletionBlockDirSuffix || ext == tmpForCreationBlockDirSuffix || ext == tmpLegacy {
|
||||
if _, err := ulid.ParseStrict(fn[:len(fn)-len(ext)]); err == nil {
|
||||
return true
|
||||
}
|
||||
|
@ -2795,15 +2795,20 @@ func TestOpen_VariousBlockStates(t *testing.T) {
|
||||
require.NoError(t, os.Remove(filepath.Join(dir, metaFilename)))
|
||||
}
|
||||
{
|
||||
// Tmp blocks during creation & deletion; those should be removed on start.
|
||||
// Tmp blocks during creation; those should be removed on start.
|
||||
dir := createBlock(t, tmpDir, genSeries(10, 2, 30, 40))
|
||||
require.NoError(t, fileutil.Replace(dir, dir+tmpForCreationBlockDirSuffix))
|
||||
expectedRemovedDirs[dir+tmpForCreationBlockDirSuffix] = struct{}{}
|
||||
|
||||
// Tmp blocks during creation & deletion; those should be removed on start.
|
||||
// Tmp blocks during deletion; those should be removed on start.
|
||||
dir = createBlock(t, tmpDir, genSeries(10, 2, 40, 50))
|
||||
require.NoError(t, fileutil.Replace(dir, dir+tmpForDeletionBlockDirSuffix))
|
||||
expectedRemovedDirs[dir+tmpForDeletionBlockDirSuffix] = struct{}{}
|
||||
|
||||
// Pre-2.21 tmp blocks; those should be removed on start.
|
||||
dir = createBlock(t, tmpDir, genSeries(10, 2, 50, 60))
|
||||
require.NoError(t, fileutil.Replace(dir, dir+tmpLegacy))
|
||||
expectedRemovedDirs[dir+tmpLegacy] = struct{}{}
|
||||
}
|
||||
{
|
||||
// One ok block; but two should be replaced.
|
||||
|
Loading…
Reference in New Issue
Block a user