mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: fix a bug, which prevents from reading pre-v1.90.0 parts
The bug has been introduced in c0b852d50d
This commit is contained in:
parent
cf4701db65
commit
f26e480a77
1 changed files with 13 additions and 12 deletions
|
@ -135,20 +135,21 @@ func (ph *partHeader) MustReadMetadata(partPath string) {
|
||||||
ph.Reset()
|
ph.Reset()
|
||||||
|
|
||||||
metadataPath := filepath.Join(partPath, metadataFilename)
|
metadataPath := filepath.Join(partPath, metadataFilename)
|
||||||
metadata, err := os.ReadFile(metadataPath)
|
if !fs.IsPathExist(metadataPath) {
|
||||||
if err != nil {
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
// This is a part created before v1.90.0.
|
// This is a part created before v1.90.0.
|
||||||
// Fall back to reading the metadata from the partPath itsel
|
// Fall back to reading the metadata from the partPath itsel
|
||||||
if err := ph.ParseFromPath(partPath); err != nil {
|
if err := ph.ParseFromPath(partPath); err != nil {
|
||||||
logger.Panicf("FATAL: cannot parse metadata from %q: %s", partPath, err)
|
logger.Panicf("FATAL: cannot parse metadata from %q: %s", partPath, err)
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
metadata, err := os.ReadFile(metadataPath)
|
||||||
|
if err != nil {
|
||||||
logger.Panicf("FATAL: cannot read %q: %s", metadataPath, err)
|
logger.Panicf("FATAL: cannot read %q: %s", metadataPath, err)
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(metadata, ph); err != nil {
|
if err := json.Unmarshal(metadata, ph); err != nil {
|
||||||
logger.Panicf("FATAL: cannot parse %q: %s", metadataPath, err)
|
logger.Panicf("FATAL: cannot parse %q: %s", metadataPath, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Perform various checks
|
// Perform various checks
|
||||||
if ph.MinTimestamp > ph.MaxTimestamp {
|
if ph.MinTimestamp > ph.MaxTimestamp {
|
||||||
|
|
Loading…
Reference in a new issue