More header download diagnostics (#4224)

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2022-05-21 14:49:08 +01:00 committed by GitHub
parent 54cf932652
commit e6cb086c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -821,7 +821,7 @@ Loop:
log.Info("Req/resp stats", "req", reqCount, "reqMin", reqMin, "reqMax", reqMax,
"skel", skeletonReqCount, "skelMin", skeletonReqMin, "skelMax", skeletonReqMax,
"resp", respCount, "respMin", respMin, "respMax", respMax)
cfg.hd.LogAnchorState()
if noProgressCounter >= 5 && wasProgress {
log.Warn("Looks like chain is not progressing, moving to the next stage")
break Loop

View File

@ -212,13 +212,13 @@ func (hd *HeaderDownload) pruneLinkQueue() {
}
}
func (hd *HeaderDownload) AnchorState() string {
func (hd *HeaderDownload) LogAnchorState() {
hd.lock.RLock()
defer hd.lock.RUnlock()
return hd.anchorState()
hd.logAnchorState()
}
func (hd *HeaderDownload) anchorState() string {
func (hd *HeaderDownload) logAnchorState() {
//nolint:prealloc
var ss []string
for anchorParent, anchor := range hd.anchors {
@ -276,7 +276,9 @@ func (hd *HeaderDownload) anchorState() string {
ss = append(ss, sb.String())
}
sort.Strings(ss)
return strings.Join(ss, "\n")
for _, s := range ss {
log.Info(s)
}
}
func (hd *HeaderDownload) RecoverFromDb(db kv.RoDB) error {
@ -877,7 +879,7 @@ func (hd *HeaderDownload) ProcessHeader(sh ChainSegmentHeader, newBlock bool, pe
return false
}
if len(hd.anchors) >= hd.anchorLimit {
log.Debug(fmt.Sprintf("too many anchors: %d, limit %d, state: %s", len(hd.anchors), hd.anchorLimit, hd.anchorState()))
log.Debug(fmt.Sprintf("too many anchors: %d, limit %d", len(hd.anchors), hd.anchorLimit))
return false
}
}