From aa87083235ac23137aefd049f4548b1a10072357 Mon Sep 17 00:00:00 2001 From: MozirDmitriy Date: Fri, 11 Jul 2025 17:56:42 +0300 Subject: [PATCH] Replace defer with explicit Close() calls in export/import loops --- benchmarks/cosmos-exim/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmarks/cosmos-exim/main.go b/benchmarks/cosmos-exim/main.go index 9a7fe7824..4b4a6ba29 100644 --- a/benchmarks/cosmos-exim/main.go +++ b/benchmarks/cosmos-exim/main.go @@ -126,7 +126,6 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) { if err != nil { return 0, nil, err } - defer exporter.Close() for { node, err := exporter.Next() if errors.Is(err, iavl.ErrorExportDone) { @@ -137,6 +136,7 @@ func runExport(dbPath string) (int64, map[string][]*iavl.ExportNode, error) { export = append(export, node) stats.AddNode(node) } + exporter.Close() stats.AddDurationSince(start) fmt.Printf("%-13v: %v\n", name, stats.String()) totalStats.Add(stats) @@ -173,7 +173,6 @@ func runImport(version int64, exports map[string][]*iavl.ExportNode) error { if err != nil { return err } - defer importer.Close() for _, node := range exports[name] { err = importer.Add(node) if err != nil { @@ -185,6 +184,7 @@ func runImport(version int64, exports map[string][]*iavl.ExportNode) error { if err != nil { return err } + importer.Close() stats.AddDurationSince(start) fmt.Printf("%-12v: %v\n", name, stats.String()) totalStats.Add(stats)