From 8433f81b6877b4ecd268bce74f69724f102a2cf1 Mon Sep 17 00:00:00 2001 From: Seebs Date: Fri, 1 Oct 2021 11:00:55 -0500 Subject: [PATCH] don't close storage after failing to open cache If the inner function that handles the open of storage and cache fails, we close the fragment. If we closeStorage() before that, then we can try to close the storage again, which causes a panic when we try to mark the generation as Done again. I was going to set f.gen = nil after marking it done, but I'm not feeling safe about that -- there's too many places where we check things about f.gen, and it seems unsafe. The generation code should be removed at some point, because it all exists as a workaround for not having any way to detect when reads are "done", because we didn't want to do something huge and intrusive, like adding the Tx system and requiring transactions to get closed. --- fragment.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fragment.go b/fragment.go index d545a1726..daab8bb34 100644 --- a/fragment.go +++ b/fragment.go @@ -286,10 +286,6 @@ func (f *fragment) Open() error { // Fill cache with rows persisted to disk. f.holder.Logger.Debugf("open cache for index/field/view/fragment: %s/%s/%s/%d", f.index(), f.field(), f.view(), f.shard) if err := f.openCache(); err != nil { - e2 := f.closeStorage() - if e2 != nil { - return errors.Wrapf(err, "closing storage: %v, after opening cache", e2) - } return errors.Wrap(err, "opening cache") }