Fix activity log fragment race test (#11565)
* grab reference to done channel while locked * add clarifying comment * lock and grab channel reference again for test races
This commit is contained in:
parent
91ed71c296
commit
ee53fc5afb
|
@ -1125,9 +1125,14 @@ func (a *ActivityLog) activeFragmentWorker() {
|
|||
}
|
||||
}
|
||||
|
||||
// we modify the doneCh in some tests, so let's make sure we don't trip
|
||||
// the race detector
|
||||
a.l.RLock()
|
||||
doneCh := a.doneCh
|
||||
a.l.RUnlock()
|
||||
for {
|
||||
select {
|
||||
case <-a.doneCh:
|
||||
case <-doneCh:
|
||||
// Shutting down activity log.
|
||||
ticker.Stop()
|
||||
return
|
||||
|
@ -1707,9 +1712,12 @@ func (a *ActivityLog) retentionWorker(currentTime time.Time, retentionMonths int
|
|||
|
||||
// Cancel the context if activity log is shut down.
|
||||
// This will cause the next storage operation to fail.
|
||||
a.l.RLock()
|
||||
doneCh := a.doneCh
|
||||
a.l.RUnlock()
|
||||
go func() {
|
||||
select {
|
||||
case <-a.doneCh:
|
||||
case <-doneCh:
|
||||
cancel()
|
||||
case <-ctx.Done():
|
||||
break
|
||||
|
|
|
@ -1386,7 +1386,9 @@ func TestActivityLog_refreshFromStoredLogWithBackgroundLoadingCancelled(t *testi
|
|||
var wg sync.WaitGroup
|
||||
close(a.doneCh)
|
||||
defer func() {
|
||||
a.l.Lock()
|
||||
a.doneCh = make(chan struct{}, 1)
|
||||
a.l.Unlock()
|
||||
}()
|
||||
|
||||
err := a.refreshFromStoredLog(context.Background(), &wg, time.Now().UTC())
|
||||
|
|
Loading…
Reference in New Issue