transition out of initial sync only if sync finishes within 15min
This commit is contained in:
parent
8702ff8b7e
commit
a650641813
@ -22,6 +22,8 @@ var (
|
|||||||
MaxSyncWorkers = 5
|
MaxSyncWorkers = 5
|
||||||
SyncWorkerHistory = 3
|
SyncWorkerHistory = 3
|
||||||
|
|
||||||
|
InitialSyncTimeThreshold = 15 * time.Minute
|
||||||
|
|
||||||
coalesceTipsets = false
|
coalesceTipsets = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -87,6 +89,7 @@ type workerState struct {
|
|||||||
id uint64
|
id uint64
|
||||||
ts *types.TipSet
|
ts *types.TipSet
|
||||||
ss *SyncerState
|
ss *SyncerState
|
||||||
|
dt time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type workerStatus struct {
|
type workerStatus struct {
|
||||||
@ -240,8 +243,10 @@ func (sm *syncManager) handleWorkerStatus(status workerStatus) {
|
|||||||
} else {
|
} else {
|
||||||
// add to the recently synced buffer
|
// add to the recently synced buffer
|
||||||
sm.recent.Push(ws.ts)
|
sm.recent.Push(ws.ts)
|
||||||
// mark the end of the initial sync
|
// if we are still in intial sync and this was fast enough, mark the end of the initial sync
|
||||||
sm.initialSyncDone = true
|
if !sm.initialSyncDone && ws.dt < InitialSyncTimeThreshold {
|
||||||
|
sm.initialSyncDone = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we are done with this target, select the next sync target and spawn a worker if there is work
|
// we are done with this target, select the next sync target and spawn a worker if there is work
|
||||||
@ -302,7 +307,8 @@ func (sm *syncManager) worker(ws *workerState) {
|
|||||||
ctx := context.WithValue(sm.ctx, syncStateKey{}, ws.ss)
|
ctx := context.WithValue(sm.ctx, syncStateKey{}, ws.ss)
|
||||||
err := sm.doSync(ctx, ws.ts)
|
err := sm.doSync(ctx, ws.ts)
|
||||||
|
|
||||||
log.Infof("worker %d done; took %s", ws.id, build.Clock.Since(start))
|
ws.dt = build.Clock.Since(start)
|
||||||
|
log.Infof("worker %d done; took %s", ws.id, ws.dt)
|
||||||
select {
|
select {
|
||||||
case sm.statusq <- workerStatus{id: ws.id, err: err}:
|
case sm.statusq <- workerStatus{id: ws.id, err: err}:
|
||||||
case <-sm.ctx.Done():
|
case <-sm.ctx.Done():
|
||||||
|
Loading…
Reference in New Issue
Block a user