shards: clear out shards map when closing
If something calls the sharded searcher after closing it will lead to a
panic since shards will have shards which are closed. In practice this
can happen with the directory watcher. The issue with the directory
watcher is fixed in a later commit.
Change-Id: I11a2300ff9ffc41f3be94ebb550b16c6c68ac59b
diff --git a/shards/shards.go b/shards/shards.go
index 98e51db..4eceb32 100644
--- a/shards/shards.go
+++ b/shards/shards.go
@@ -195,6 +195,7 @@
for _, s := range ss.shards {
s.Close()
}
+ ss.shards = make(map[string]rankedShard)
}
func (ss *shardedSearcher) Search(ctx context.Context, q query.Q, opts *zoekt.SearchOptions) (sr *zoekt.SearchResult, err error) {