mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage/partition: add check to ensure parts exist on disk (#5017)
* lib/storage/partition: add check to ensure parts exist on disk If part exists in parts.json but is missing on disk there will be a misleading error similar to "unexpected number of substrings in the part name". This change forces verification of part existence and throws a correct error in case it is missing on disk. Such issue can be result of https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5005 or disk corruption. Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * lib/storage/partition: use filepath.Join instead of string concatenation Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * lib/storage/partition: add action points for error message Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> * all: add a check for missing part in lib/mergeset and lib/logstorage --------- Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com> Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
This commit is contained in:
parent
28aed4d098
commit
bea3431ed1
3 changed files with 35 additions and 0 deletions
|
@ -149,7 +149,18 @@ func mustOpenDatadb(pt *partition, path string, flushInterval time.Duration) *da
|
|||
|
||||
pws := make([]*partWrapper, len(partNames))
|
||||
for i, partName := range partNames {
|
||||
// Make sure the partName exists on disk.
|
||||
// If it is missing, then manual action from the user is needed,
|
||||
// since this is unexpected state, which cannot occur under normal operation,
|
||||
// including unclean shutdown.
|
||||
partPath := filepath.Join(path, partName)
|
||||
if !fs.IsPathExist(partPath) {
|
||||
partsFile := filepath.Join(path, partsFilename)
|
||||
logger.Panicf("FATAL: part %q is listed in %q, but is missing on disk; "+
|
||||
"ensure %q contents is not corrupted; remove %q to rebuild its' content from the list of existing parts",
|
||||
partPath, partsFile, partsFile, partsFile)
|
||||
}
|
||||
|
||||
p := mustOpenFilePart(pt, partPath)
|
||||
pws[i] = newPartWrapper(p, nil, time.Time{})
|
||||
}
|
||||
|
|
|
@ -1349,6 +1349,18 @@ func mustOpenParts(path string) []*partWrapper {
|
|||
des := fs.MustReadDir(path)
|
||||
m := make(map[string]struct{}, len(partNames))
|
||||
for _, partName := range partNames {
|
||||
// Make sure the partName exists on disk.
|
||||
// If it is missing, then manual action from the user is needed,
|
||||
// since this is unexpected state, which cannot occur under normal operation,
|
||||
// including unclean shutdown.
|
||||
partPath := filepath.Join(path, partName)
|
||||
if !fs.IsPathExist(partPath) {
|
||||
partsFile := filepath.Join(path, partsFilename)
|
||||
logger.Panicf("FATAL: part %q is listed in %q, but is missing on disk; "+
|
||||
"ensure %q contents is not corrupted; remove %q to rebuild its' content from the list of existing parts",
|
||||
partPath, partsFile, partsFile, partsFile)
|
||||
}
|
||||
|
||||
m[partName] = struct{}{}
|
||||
}
|
||||
for _, de := range des {
|
||||
|
|
|
@ -1779,6 +1779,18 @@ func mustOpenParts(path string, partNames []string) []*partWrapper {
|
|||
des := fs.MustReadDir(path)
|
||||
m := make(map[string]struct{}, len(partNames))
|
||||
for _, partName := range partNames {
|
||||
// Make sure the partName exists on disk.
|
||||
// If it is missing, then manual action from the user is needed,
|
||||
// since this is unexpected state, which cannot occur under normal operation,
|
||||
// including unclean shutdown.
|
||||
partPath := filepath.Join(path, partName)
|
||||
if !fs.IsPathExist(partPath) {
|
||||
partsFile := filepath.Join(path, partsFilename)
|
||||
logger.Panicf("FATAL: part %q is listed in %q, but is missing on disk; "+
|
||||
"ensure %q contents is not corrupted; remove %q to rebuild its' content from the list of existing parts",
|
||||
partPath, partsFile, partsFile, partsFile)
|
||||
}
|
||||
|
||||
m[partName] = struct{}{}
|
||||
}
|
||||
for _, de := range des {
|
||||
|
|
Loading…
Reference in a new issue