Skip to content
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

Merged
merged 2 commits into from
Apr 28, 2020
Merged

fix: non-blocking peerlog logging #7232

merged 2 commits into from
Apr 28, 2020

Conversation

Stebalien
Copy link
Member

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.

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.
@Stebalien
Copy link
Member Author

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.

"peer", conn.RemotePeer().Pretty(),
)
}
notifee.DisconnectedF = func(net network.Network, conn network.Conn) {
Copy link
Member Author

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(&notifee)

sub, err := node.PeerHost.EventBus().Subscribe(
new(event.EvtPeerIdentificationCompleted),
eventbus.BufSize(1024),
Copy link
Member Author

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,
Copy link
Member Author

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).

plugin/plugins/peerlog/peerlog.go Outdated Show resolved Hide resolved
plugin/plugins/peerlog/peerlog.go Show resolved Hide resolved
@willscott
Copy link
Contributor

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.

@Stebalien
Copy link
Member Author

I believe the real issue is writing to stdout. We usually only enable error logging which is very low-throughput.

@Stebalien Stebalien merged commit 512050f into master Apr 28, 2020
@hacdias hacdias deleted the fix/less-verbose branch May 9, 2023 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants