From d5d32f43647fef3e16772ebf29f158b01a8febab Mon Sep 17 00:00:00 2001 From: Andrew Sisley Date: Mon, 14 Feb 2022 13:50:56 -0500 Subject: [PATCH] Close fetcher on error --- db/collection_get.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/collection_get.go b/db/collection_get.go index 0cee5d936d..d5ec3a7874 100644 --- a/db/collection_get.go +++ b/db/collection_get.go @@ -51,6 +51,7 @@ func (c *Collection) get(ctx context.Context, txn *Txn, key key.DocKey) (*docume // initialize it with the primary index err := df.Init(&c.desc, &c.desc.Indexes[0], nil, false) if err != nil { + _ = df.Close() return nil, err } @@ -59,12 +60,14 @@ func (c *Collection) get(ctx context.Context, txn *Txn, key key.DocKey) (*docume // run the doc fetcher err = df.Start(ctx, txn, core.Spans{core.NewSpan(targetKey, targetKey.PrefixEnd())}) if err != nil { + _ = df.Close() return nil, err } // return first matched decoded doc doc, err := df.FetchNextDecoded(ctx) if err != nil { + _ = df.Close() return nil, err }