Open
Description
When runningFn is called, the goroutine is blocked.
thanos/internal/cortex/util/services/basic_service.go
Lines 192 to 194 in da855a1
The b.serviceCancel() can awaken the blocked goroutine. However, because the goroutine has blocked at runningFn. So the statement can't get executed, resulting in the gouroutine leak.
How to fix the bug:
I provide a solution that involves calling runningFn in a new goroutine to ensure the execution of serviceCancel(), as follows.
go func() {
err = b.runningFn(b.serviceContext)
}()