waitForBGTCompletion waits for all the background tasks to finish.
(ctx context.Context, waitTimeMax time.Duration, tasks []BackgroundTask, dbName string)
| 729 | |
| 730 | // waitForBGTCompletion waits for all the background tasks to finish. |
| 731 | func waitForBGTCompletion(ctx context.Context, waitTimeMax time.Duration, tasks []BackgroundTask, dbName string) { |
| 732 | waitTime := waitTimeMax |
| 733 | for _, t := range tasks { |
| 734 | start := time.Now() |
| 735 | select { |
| 736 | case <-t.doneChan: |
| 737 | waitTime -= time.Now().Sub(start) |
| 738 | continue |
| 739 | case <-time.After(waitTime): |
| 740 | // Timeout after waiting for background task to terminate. |
| 741 | } |
| 742 | base.InfofCtx(ctx, base.KeyAll, "Timeout after %v of waiting for background task %q to "+ |
| 743 | "terminate, database: %s", waitTimeMax, t.taskName, dbName) |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | func (context *DatabaseContext) IsClosed() bool { |
| 748 | context.BucketLock.RLock() |