Merge pull request #8432 from roidelapluie/backfillpanic

backfill: move checkErr before we close the mmaped file
This commit is contained in:
Julien Pivotto 2021-02-03 16:32:35 +01:00 committed by GitHub
commit c1f8bd9944
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -207,7 +207,7 @@ func main() {
os.Exit(checkErr(dumpSamples(*dumpPath, *dumpMinTime, *dumpMaxTime)))
//TODO(aSquare14): Work on adding support for custom block size.
case openMetricsImportCmd.FullCommand():
os.Exit(checkErr(backfillOpenMetrics(*importFilePath, *importDBPath, *importHumanReadable)))
os.Exit(backfillOpenMetrics(*importFilePath, *importDBPath, *importHumanReadable))
}
}

View file

@ -618,16 +618,16 @@ func checkErr(err error) int {
return 0
}
func backfillOpenMetrics(path string, outputDir string, humanReadable bool) (err error) {
func backfillOpenMetrics(path string, outputDir string, humanReadable bool) int {
inputFile, err := fileutil.OpenMmapFile(path)
if err != nil {
return err
return checkErr(err)
}
defer inputFile.Close()
if err := os.MkdirAll(outputDir, 0777); err != nil {
return errors.Wrap(err, "create output dir")
return checkErr(errors.Wrap(err, "create output dir"))
}
return backfill(5000, inputFile.Bytes(), outputDir, humanReadable)
return checkErr(backfill(5000, inputFile.Bytes(), outputDir, humanReadable))
}