Wait for asynchronous deletion to finish before restarting. (#10345)
This commit is contained in:
parent
a361d1299b
commit
52ddad2bc5
|
@ -732,6 +732,19 @@ func (a *ActivityLog) deleteLogWorker(startTimestamp int64, whenDone chan struct
|
|||
close(whenDone)
|
||||
}
|
||||
|
||||
func (a *ActivityLog) WaitForDeletion() {
|
||||
a.l.Lock()
|
||||
// May be nil, if never set
|
||||
doneCh := a.deleteDone
|
||||
a.l.Unlock()
|
||||
if doneCh != nil {
|
||||
select {
|
||||
case <-doneCh:
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// refreshFromStoredLog loads the appropriate entities/tokencounts for active and performance standbys
|
||||
// the most recent segment is loaded synchronously, and older segments are loaded in the background
|
||||
// this function expects stateLock to be held
|
||||
|
|
|
@ -1238,6 +1238,13 @@ func TestActivityLog_StopAndRestart(t *testing.T) {
|
|||
DefaultReportMonths: 12,
|
||||
})
|
||||
|
||||
// On enterprise, a segment will be created, and
|
||||
// disabling it will trigger deletion, so wait
|
||||
// for that deletion to finish.
|
||||
// (Alternatively, we could ensure that the next segment
|
||||
// uses a different timestamp by waiting 1 second.)
|
||||
a.WaitForDeletion()
|
||||
|
||||
// Go through request to ensure config is persisted
|
||||
req := logical.TestRequest(t, logical.UpdateOperation, "internal/counters/config")
|
||||
req.Storage = sysView
|
||||
|
|
Loading…
Reference in New Issue