Skip to content

Commit

Permalink
Merge pull request #19 from Funarp/patch-1
Browse files Browse the repository at this point in the history
Solve the multi-thread contention problem
  • Loading branch information
FroghubMan authored Apr 2, 2022
2 parents dd333d9 + 2cec276 commit 3ba9e48
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion recovery/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"strings"
"sync"
"time"
"math/rand"
)

var log = logging.Logger("recover")
Expand Down Expand Up @@ -171,9 +172,10 @@ func RecoverSealedFile(ctx context.Context, rp export.RecoveryParams, parallel u
<-limiter
}()

randNum := rand.Intn(int(parallel) * 2)
//Control PC1 running interval
for {
if time.Now().Add(-time.Minute * 10).After(p1LastTaskTime) {
if time.Now().Add(-time.Minute * 10).Add(time.Duration(randNum) * time.Second).After(p1LastTaskTime) {
break
}
<-time.After(p1LastTaskTime.Sub(time.Now()))
Expand Down

0 comments on commit 3ba9e48

Please sign in to comment.