Wait for asynchronous deletion to finish before restarting. (#10345)

This commit is contained in:
Mark Gritter 2020-11-06 16:21:04 -08:00 committed by GitHub
parent a361d1299b
commit 52ddad2bc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -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

View File

@ -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