track last few worker states for debug purposes
This commit is contained in:
parent
6266bae1d3
commit
ba2512655e
@ -20,6 +20,7 @@ var (
|
|||||||
|
|
||||||
RecentSyncBufferSize = 10
|
RecentSyncBufferSize = 10
|
||||||
MaxSyncWorkers = 5
|
MaxSyncWorkers = 5
|
||||||
|
SyncWorkerHistory = 3
|
||||||
|
|
||||||
coalesceTipsets = false
|
coalesceTipsets = false
|
||||||
)
|
)
|
||||||
@ -69,6 +70,9 @@ type syncManager struct {
|
|||||||
mx sync.Mutex
|
mx sync.Mutex
|
||||||
state map[uint64]*workerState
|
state map[uint64]*workerState
|
||||||
|
|
||||||
|
history []*workerState
|
||||||
|
historyI int
|
||||||
|
|
||||||
doSync func(context.Context, *types.TipSet) error
|
doSync func(context.Context, *types.TipSet) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +104,10 @@ func NewSyncManager(sync SyncFunc) SyncManager {
|
|||||||
workq: make(chan peerHead),
|
workq: make(chan peerHead),
|
||||||
statusq: make(chan workerStatus),
|
statusq: make(chan workerStatus),
|
||||||
|
|
||||||
heads: make(map[peer.ID]*types.TipSet),
|
heads: make(map[peer.ID]*types.TipSet),
|
||||||
state: make(map[uint64]*workerState),
|
state: make(map[uint64]*workerState),
|
||||||
recent: newSyncBuffer(RecentSyncBufferSize),
|
recent: newSyncBuffer(RecentSyncBufferSize),
|
||||||
|
history: make([]*workerState, SyncWorkerHistory),
|
||||||
|
|
||||||
doSync: sync,
|
doSync: sync,
|
||||||
}
|
}
|
||||||
@ -134,6 +139,11 @@ func (sm *syncManager) State() []SyncerStateSnapshot {
|
|||||||
for _, ws := range sm.state {
|
for _, ws := range sm.state {
|
||||||
workerStates = append(workerStates, ws)
|
workerStates = append(workerStates, ws)
|
||||||
}
|
}
|
||||||
|
for _, ws := range sm.history {
|
||||||
|
if ws != nil {
|
||||||
|
workerStates = append(workerStates, ws)
|
||||||
|
}
|
||||||
|
}
|
||||||
sm.mx.Unlock()
|
sm.mx.Unlock()
|
||||||
|
|
||||||
sort.Slice(workerStates, func(i, j int) bool {
|
sort.Slice(workerStates, func(i, j int) bool {
|
||||||
@ -216,6 +226,11 @@ func (sm *syncManager) handleWorkerStatus(status workerStatus) {
|
|||||||
sm.mx.Lock()
|
sm.mx.Lock()
|
||||||
ws := sm.state[status.id]
|
ws := sm.state[status.id]
|
||||||
delete(sm.state, status.id)
|
delete(sm.state, status.id)
|
||||||
|
|
||||||
|
// we track the last few workers for debug purposes
|
||||||
|
sm.history[sm.historyI] = ws
|
||||||
|
sm.historyI++
|
||||||
|
sm.historyI %= len(sm.history)
|
||||||
sm.mx.Unlock()
|
sm.mx.Unlock()
|
||||||
|
|
||||||
if status.err != nil {
|
if status.err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user