From bf7726d130716fdcdeea316e8d8284bb51412454 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 8 Jul 2023 20:53:41 +1000 Subject: [PATCH] Fix race condition We had some test flakiness involving the index.lock file which is fixed by this commit. We shouldn't be accessing newTaskID without the mutex, although I'm surprised that this actually fixes the issue. Surely we don't have tasks (which typically render to the main view) which use index.lock? --- pkg/tasks/tasks.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 58784da5f..8edcbfea2 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -324,10 +324,13 @@ func (self *ViewBufferManager) NewTask(f func(TaskOpts) error, key string) error self.waitingMutex.Lock() + self.taskIDMutex.Lock() if taskID < self.newTaskID { self.waitingMutex.Unlock() + self.taskIDMutex.Unlock() return } + self.taskIDMutex.Unlock() if self.stopCurrentTask != nil { self.stopCurrentTask()