-
Notifications
You must be signed in to change notification settings - Fork 186
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
make message large message handling robust and noisy #189
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -342,15 +342,25 @@ func (gs *GossipSubRouter) sendRPC(p peer.ID, out *RPC) { | |
return | ||
} | ||
|
||
select { | ||
case mch <- out: | ||
default: | ||
log.Infof("dropping message to peer %s: queue full", p) | ||
// push control messages that need to be retried | ||
ctl := out.GetControl() | ||
if ctl != nil { | ||
gs.pushControl(p, ctl) | ||
if out.Size() > maxRPCSize { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here too, this check seems unnecessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm worried we could add too much gossip. That's why I have that check. But I can remove it if you think it's overkill. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, this check is reasonable on second thought, if we are adding too much gossip (over 64KB) we probably want to know. |
||
log.Errorf( | ||
"dropping RPC outbound message that's too large: %d > %d", | ||
out.Size(), | ||
maxRPCSize, | ||
) | ||
} else { | ||
select { | ||
case mch <- out: | ||
return | ||
default: | ||
} | ||
log.Infof("dropping message to peer %s: queue full", p) | ||
} | ||
|
||
// push control messages that need to be retried | ||
ctl := out.GetControl() | ||
if ctl != nil { | ||
gs.pushControl(p, ctl) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,13 @@ var ( | |
TimeCacheDuration = 120 * time.Second | ||
) | ||
|
||
const ( | ||
// maxRPCSize is the maximum size of any RPC protobuf. | ||
maxRPCSize = maxMessageSize + (64 * 1024) // a message + 64 KiB. | ||
/// maxMessageSize is the maximum size of outbound message. | ||
maxMessageSize = 1 << 20 // 1MiB | ||
vyzo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
var log = logging.Logger("pubsub") | ||
|
||
// PubSub is the implementation of the pubsub system. | ||
|
@@ -696,7 +703,12 @@ func (p *PubSub) GetTopics() []string { | |
} | ||
|
||
// Publish publishes data to the given topic. | ||
// | ||
// The message data must be less than the maximum message size, 1MiB. | ||
func (p *PubSub) Publish(topic string, data []byte) error { | ||
if len(data) > 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BUG: that should be
|
||
return fmt.Errorf("message too large: %d > %d", len(data), maxMessageSize) | ||
} | ||
seqno := p.nextSeqno() | ||
m := &pb.Message{ | ||
Data: data, | ||
|
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.
Is this check really necessary here?
We already drop large messages on publish and can't read messages larger than maxRCPSize anyway.
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.
I guess it should be fine in floodsub. My worry is gossipsub.
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.
well, let's remove it from here as it's redundant, and rethink the gossipsub case.
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.
This can't hurt and future proofs us against, e.g., batching too many messages in a single RPC and then silently failing when the remote side drops it.