cli: release resources occupied by chain before dumpDB
exit
Problem: ``` --- FAIL: TestDumpDB (0.08s) --- FAIL: TestDumpDB/too_low_chain testing.go:894: TempDir RemoveAll cleanup: remove C:\Users\Anna\AppData\Local\Temp\TestDumpDB_too_low_chain357310492\001\chains\privnet\000001.log: The process cannot access the file because it is being used by another process. ``` Solution: Release resources occupied by the chain even on non-error command exit.
This commit is contained in:
parent
aefb6f9fee
commit
16da133d61
1 changed files with 5 additions and 3 deletions
|
@ -186,6 +186,11 @@ func dumpDB(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
pprof.ShutDown()
|
||||||
|
prometheus.ShutDown()
|
||||||
|
chain.Close()
|
||||||
|
}()
|
||||||
|
|
||||||
chainCount := chain.BlockHeight() + 1
|
chainCount := chain.BlockHeight() + 1
|
||||||
if start+count > chainCount {
|
if start+count > chainCount {
|
||||||
|
@ -199,9 +204,6 @@ func dumpDB(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(err.Error(), 1)
|
return cli.NewExitError(err.Error(), 1)
|
||||||
}
|
}
|
||||||
pprof.ShutDown()
|
|
||||||
prometheus.ShutDown()
|
|
||||||
chain.Close()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue