From e6cb086c907109e8cd4df9ad5e9bc80c279701c9 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Sat, 21 May 2022 14:49:08 +0100 Subject: [PATCH] More header download diagnostics (#4224) Co-authored-by: Alexey Sharp --- eth/stagedsync/stage_headers.go | 2 +- turbo/stages/headerdownload/header_algos.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/eth/stagedsync/stage_headers.go b/eth/stagedsync/stage_headers.go index 84d359ddc..003679872 100644 --- a/eth/stagedsync/stage_headers.go +++ b/eth/stagedsync/stage_headers.go @@ -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 diff --git a/turbo/stages/headerdownload/header_algos.go b/turbo/stages/headerdownload/header_algos.go index 43c58a5c6..1d2de0f1e 100644 --- a/turbo/stages/headerdownload/header_algos.go +++ b/turbo/stages/headerdownload/header_algos.go @@ -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 } }