integration: cancel warmup (#6494)

This commit is contained in:
Alex Sharov 2023-01-03 12:51:00 +07:00 committed by GitHub
parent ac6f2e1067
commit 0483fc5539
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -229,8 +229,6 @@ func WarmupTable(ctx context.Context, db kv.RoDB, bucket string, lvl log.Lvl) {
logEvery := time.NewTicker(20 * time.Second)
defer logEvery.Stop()
//0000000000a8a7b800000044
g, ctx := errgroup.WithContext(ctx)
g.SetLimit(ThreadsLimit)
for i := 0; i < 256; i++ {
@ -248,7 +246,10 @@ func WarmupTable(ctx context.Context, db kv.RoDB, bucket string, lvl log.Lvl) {
if err != nil {
return err
}
progress.Inc()
select {
case <-ctx.Done():
return ctx.Err()
case <-logEvery.C:
log.Log(lvl, fmt.Sprintf("Progress: %s %.2f%%", bucket, 100*float64(progress.Load())/float64(total)))
default:
@ -275,6 +276,8 @@ func WarmupTable(ctx context.Context, db kv.RoDB, bucket string, lvl log.Lvl) {
return err
}
select {
case <-ctx.Done():
return ctx.Err()
case <-logEvery.C:
log.Log(lvl, fmt.Sprintf("Progress: %s %.2f%%", bucket, 100*float64(progress.Load())/float64(total)))
default: