-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: non-blocking peerlog logging #7232
Conversation
4580d78
to
0b0c6c9
Compare
Avoid ever blocking new connections in the peer logger. Instead: 1. Send all new peers to a highly buffered channel. 2. Emit "dropped event" errors whenever we detect that we're dropping events and falling behind. 3. Don't log protocols, they're too large. 4. Don't log disconnects, we don't need them.
0b0c6c9
to
bdbb79d
Compare
Context: this is the plugin we use to count peers in the network. Unfortunately, something sometimes goes wrong with logging and it starts blocking. When that happens, we end up halting everything because we can't log. This logs from a separate goroutine when we can so we don't completely block everything else. |
7502e35
to
20ad9f2
Compare
"peer", conn.RemotePeer().Pretty(), | ||
) | ||
} | ||
notifee.DisconnectedF = func(net network.Network, conn network.Conn) { |
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.
We're intentionally removing this event.
} | ||
node.PeerHost.Network().Notify(¬ifee) | ||
|
||
sub, err := node.PeerHost.EventBus().Subscribe( | ||
new(event.EvtPeerIdentificationCompleted), | ||
eventbus.BufSize(1024), |
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.
There's a default buffer size of 16 and that should be enough for us now.
"identified", | ||
"peer", e.Peer.Pretty(), | ||
"agent", agent, | ||
"protocols", protocols, |
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.
We're removing the protocols (too much data).
odd that this is the place where logging gets backed up. it doesn't seem like that much more than what other parts of the system are logging. |
I believe the real issue is writing to stdout. We usually only enable error logging which is very low-throughput. |
20ad9f2
to
a10a14f
Compare
Avoid ever blocking new connections in the peer logger. Instead: