Skip to content

Commit

Permalink
fix: Add data race protection for the tm.wg var (#12100)
Browse files Browse the repository at this point in the history
paul1r authored Feb 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b24d48d commit 77a2580
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 77a2580

Please sign in to comment.