mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
lib/storage: load metadata before loading indexdb, since indexdb depends on the metadata
This commit is contained in:
parent
08f21d8761
commit
eeb92eb7fc
1 changed files with 8 additions and 8 deletions
|
@ -177,10 +177,17 @@ func OpenStorage(path string, retentionMsecs int64) (*Storage, error) {
|
||||||
|
|
||||||
s.prefetchedMetricIDs.Store(&uint64set.Set{})
|
s.prefetchedMetricIDs.Store(&uint64set.Set{})
|
||||||
|
|
||||||
|
// Load metadata
|
||||||
|
metadataDir := path + "/metadata"
|
||||||
|
isEmptyDB := !fs.IsPathExist(path + "/indexdb")
|
||||||
|
if err := fs.MkdirAllIfNotExist(metadataDir); err != nil {
|
||||||
|
return nil, fmt.Errorf("cannot create %q: %w", metadataDir, err)
|
||||||
|
}
|
||||||
|
s.minTimestampForCompositeIndex = mustGetMinTimestampForCompositeIndex(metadataDir, isEmptyDB)
|
||||||
|
|
||||||
// Load indexdb
|
// Load indexdb
|
||||||
idbPath := path + "/indexdb"
|
idbPath := path + "/indexdb"
|
||||||
idbSnapshotsPath := idbPath + "/snapshots"
|
idbSnapshotsPath := idbPath + "/snapshots"
|
||||||
isEmptyDB := !fs.IsPathExist(idbPath)
|
|
||||||
if err := fs.MkdirAllIfNotExist(idbSnapshotsPath); err != nil {
|
if err := fs.MkdirAllIfNotExist(idbSnapshotsPath); err != nil {
|
||||||
return nil, fmt.Errorf("cannot create %q: %w", idbSnapshotsPath, err)
|
return nil, fmt.Errorf("cannot create %q: %w", idbSnapshotsPath, err)
|
||||||
}
|
}
|
||||||
|
@ -200,13 +207,6 @@ func OpenStorage(path string, retentionMsecs int64) (*Storage, error) {
|
||||||
}
|
}
|
||||||
s.tb = tb
|
s.tb = tb
|
||||||
|
|
||||||
// Load metadata
|
|
||||||
metadataDir := path + "/metadata"
|
|
||||||
if err := fs.MkdirAllIfNotExist(metadataDir); err != nil {
|
|
||||||
return nil, fmt.Errorf("cannot create %q: %w", metadataDir, err)
|
|
||||||
}
|
|
||||||
s.minTimestampForCompositeIndex = mustGetMinTimestampForCompositeIndex(metadataDir, isEmptyDB)
|
|
||||||
|
|
||||||
s.startCurrHourMetricIDsUpdater()
|
s.startCurrHourMetricIDsUpdater()
|
||||||
s.startNextDayMetricIDsUpdater()
|
s.startNextDayMetricIDsUpdater()
|
||||||
s.startRetentionWatcher()
|
s.startRetentionWatcher()
|
||||||
|
|
Loading…
Reference in a new issue