Merge pull request #17729 from testwill/close_profile

fix: close profile in the mvccPutFunc func
This commit is contained in:
James Blair 2024-04-12 07:01:46 +12:00 committed by GitHub
commit fa08f0196a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -77,7 +77,7 @@ func mvccPutFunc(_ *cobra.Command, _ []string) {
fmt.Fprintln(os.Stderr, "Failed to create a file for storing cpu profile result: ", err)
os.Exit(1)
}
defer f.Close()
err = pprof.StartCPUProfile(f)
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to start cpu profile: ", err)
@ -92,7 +92,7 @@ func mvccPutFunc(_ *cobra.Command, _ []string) {
fmt.Fprintln(os.Stderr, "Failed to create a file for storing heap profile result: ", err)
os.Exit(1)
}
defer f.Close()
defer func() {
err := pprof.WriteHeapProfile(f)
if err != nil {