-
Notifications
You must be signed in to change notification settings - Fork 20.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
main: fix #15858 by setting dropPeerFn in copydb #15992
Conversation
Test:
|
cmd/geth/chaincmd.go
Outdated
dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil) | ||
|
||
dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, func(id string) { | ||
log.Warn("Downloader tried to fake-peer; ignoring.", "peer", id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"fake" -> "drop"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...doh
All in all I'm a bit unsure about this PR:
|
In my case, it occurred when I was doing a measurement using @fjl's memsize tool, which stops everything and scans memory for a minute or so. I'm assuming that when it starts again, the downloader suddenly finds that the time has progressed, and that the local peer obviously hasn't responded in time. For the other cases, I'm assuming disk IO problems.
Well, worse than |
Fair point.
Ok, I can live with this PR if you can "prove" that a noop drop won't corrupt the downloader. I.e. please skim through the downloader and make sure there won't be something going wrong. |
I added a snippet so that the drop-case runs immediately after it receives a packet. It stops importing headers/receipts, and continues only downloading states... myeah it's not great... |
So if I actually do drop it, we get this:
|
Ok, maybe this is the best solution: diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index e094484..918ce9e 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -298,9 +298,7 @@ func copyDb(ctx *cli.Context) error {
syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode)
- dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, func(id string) {
- log.Warn("Downloader tried to drop fake-peer; ignoring.", "peer", id)
- })
+ dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil,nil)
// Create a source peer to satisfy downloader requests from
db, err := ethdb.NewLDBDatabase(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name), 256)
[~/go/src/github.com/ethereum/go-ethereum]
#git diff eth/downloader/downloader.go
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index b338129..1c393d3 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -853,6 +853,11 @@ func (d *Downloader) fetchHeaders(p *peerConnection, from uint64) error {
getHeaders(from)
case <-timeout.C:
+
+ if d.dropPeer == nil{
+ p.log.Warn("Downloader wants to drop peer, but peerdrop-function is not set")
+ break
+ }
// Header retrieval timed out, consider the peer bad and drop
p.log.Debug("Header request timed out", "elapsed", ttl)
headerTimeoutMeter.Mark(1) |
12950fe
to
50e7430
Compare
Ok, updated the fix to check if function is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally ok. However I'd like to ask you to add a comment above all new log.Warn messages, along the lines of:
// The dropPeer method is nil only for copydb, which can call it if compaction hits at the wrong time
eth/downloader/downloader.go
Outdated
@@ -853,6 +856,11 @@ func (d *Downloader) fetchHeaders(p *peerConnection, from uint64) error { | |||
getHeaders(from) | |||
|
|||
case <-timeout.C: | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop this empty line here.
Addressed concerns, and squashed ☑️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
… function is set (ethereum#15992)
… function is set (ethereum#15992)
Fixes #15858 by setting the peer-drop-function to non-nil.