From 51e481b95eeb7c25edc1ec6b01ae6483fda80ec3 Mon Sep 17 00:00:00 2001 From: Paul Rogers Date: Thu, 29 Feb 2024 17:07:23 -0500 Subject: [PATCH] Add protection for the tm.wg var --- .../stores/shipper/indexshipper/downloads/table_manager.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go b/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go index 21cdbc8aa41c1..8d3875afe75cd 100644 --- a/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go +++ b/pkg/storage/stores/shipper/indexshipper/downloads/table_manager.go @@ -116,7 +116,9 @@ func NewTableManager(cfg Config, openIndexFileFunc index.OpenIndexFileFunc, inde } func (tm *tableManager) loop() { + tm.tablesMtx.Lock() tm.wg.Add(1) + tm.tablesMtx.Unlock() defer tm.wg.Done() syncTicker := time.NewTicker(tm.cfg.SyncInterval) @@ -151,10 +153,10 @@ func (tm *tableManager) loop() { func (tm *tableManager) Stop() { tm.cancel() - tm.wg.Wait() tm.tablesMtx.Lock() defer tm.tablesMtx.Unlock() + tm.wg.Wait() for _, table := range tm.tables { table.Close()