Skip to content

fix: non-blocking peerlog logging#7232

Merged
Stebalien merged 2 commits intomasterfrom
fix/less-verbose
Apr 28, 2020
Merged

fix: non-blocking peerlog logging#7232
Stebalien merged 2 commits intomasterfrom
fix/less-verbose

Conversation

@Stebalien
Copy link
Copy Markdown
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 Stebalien requested a review from willscott April 28, 2020 02:17
@Stebalien
Copy link
Copy Markdown
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
Copy Markdown
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.


sub, err := node.PeerHost.EventBus().Subscribe(
new(event.EvtPeerIdentificationCompleted),
eventbus.BufSize(1024),
Copy link
Copy Markdown
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
Copy Markdown
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).

@willscott
Copy link
Copy Markdown
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
Copy Markdown
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