Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions lib/torrent/scheduler/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (c *Conn) IsClosed() bool {

func (c *Conn) readPayload(length int32) ([]byte, error) {
if err := c.bandwidth.ReserveIngress(int64(length)); err != nil {
c.log().Errorf("Error reserving ingress bandwidth for piece payload: %s", err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this log tends to show up A LOT for the origin. It's one of our most common logs that we have. I have 2 concerns:

  1. What if we get it a lot with agent too, causing a lot of noise logging?
  2. I'm not sure if it's an error, as we are just throttling ourselves intentionally. It should be an Info/Warn or even maybe a Debug log if the amount this happens is a lot.

WDYT?

@thijmv thijmv Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. It may happen when the agents are under high load, but I would expect that on the control plane. Furthermore, we currently have a nocollect rule on the agent's scheduler logs, so we can let it soak without spiking log ingestion rates.
  2. I think this is a valid point. It is not necessarily an error if we deliberately limit the bandwidth. I have downgraded the log level to INFO, as this is more appropriate than ERROR.

c.log().With("error", err).Info("Piece payload exceeded ingress bandwidth limit")
return nil, fmt.Errorf("ingress bandwidth: %s", err)
}
payload := make([]byte, length)
Expand Down Expand Up @@ -248,7 +248,7 @@ func (c *Conn) readLoop() {
default:
msg, err := c.readMessage()
if err != nil {
c.log().Infof("Error reading message from socket, exiting read loop: %s", err)
c.log().With("error", err).Debug("Error reading message from socket, exiting read loop")
return
}
c.receiver <- msg
Expand All @@ -260,8 +260,7 @@ func (c *Conn) sendPiecePayload(pr storage.PieceReader) error {
defer closers.Close(pr)

if err := c.bandwidth.ReserveEgress(int64(pr.Length())); err != nil {
// TODO(codyg): This is bad. Consider alerting here.
c.log().Errorf("Error reserving egress bandwidth for piece payload: %s", err)
c.log().With("error", err).Info("Piece payload exceeded egress bandwidth limit")
return fmt.Errorf("egress bandwidth: %s", err)
}
n, err := io.Copy(c.nc, pr)
Expand Down Expand Up @@ -300,7 +299,7 @@ func (c *Conn) writeLoop() {
return
case msg := <-c.sender:
if err := c.sendMessage(msg); err != nil {
c.log().Infof("Error writing message to socket, exiting write loop: %s", err)
c.log().With("error", err).Debug("Error writing message to socket, exiting write loop")
return
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/torrent/scheduler/conn/handshaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ type Handshaker struct {
networkEvents networkevent.Producer
peerID core.PeerID
events Events

logger *zap.SugaredLogger
}

// NewHandshaker creates a new Handshaker.
Expand Down Expand Up @@ -223,6 +225,7 @@ func NewHandshaker(
networkEvents: networkEvents,
peerID: peerID,
events: events,
logger: logger,
}, nil
}

Expand Down Expand Up @@ -359,5 +362,5 @@ func (h *Handshaker) newConn(
isPeerOrigin,
info,
openedByRemote,
zap.NewNop().Sugar())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we have a no-op logger in the past and are we 100% sure that we didn't miss any logs (that we shd move from Info/Error to Debug) that this logger is used for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it was refactored but never wired up correctly. The logger is only used for the four logs that this PR touches.

h.logger)
}
Loading