-
Notifications
You must be signed in to change notification settings - Fork 988
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
Should a NetworkBehavior
be informed about a dropped ToSwarm::NotifyHandler
event?
#5718
Comments
The behaviour can check which peers it has connection to beforehand to have a good guess on whether the event will be dropped, though this may not be reliable enough for automated systems. |
Thanks for opening and elaborating this @elenaf9.
Yeah this is true, but to be precise if I understand correctly connections in this case are This to say that it may be bug prone for Currently we don't even log when this event happens (see 1 and 2) so I suggest we at least |
Afaik there is exactly one
But what if sending the
Adding a log message sounds good to me. |
In this case I think we'd better implement the ACK ourselves along the ConnectionHandler::FromSwarm, be it a oneshot channel or else. |
Thanks for the correction Elena, yup you are right, a
yeah exactly, as we already to for |
I am not too familiar with this part of the codebase, but what @jxs suggests sounds good |
Had an off band conversation with @elenaf9 about this issue where Elena helped me recall why I think this should be addressed with more than just logging. There is currently a potential data race when a Lines 1187 to 1197 in 276ce84
Another hypothesis to try to address this situation is to try to prioritize disconnection events to always take precedence over any other |
I recall we did run into this problem and we made some work around, but I have now since forgotten the problem. Lets say we do implement an NotifyHandlerError event. Do we have an exact use-case for this right now? Like is there a behaviour that would non-trivially handle this event? |
Yes that was also what I was wondering about. Specifically: would any network behavior handle this event differently that a general connection-close event (when there are actions/ requests pending on that connection)? An action/ request can fail on many steps if the associated connection closes:
With the However, one use-case that came to my mind when talking yesterday with @jxs is that we could return in the I wonder if we instead can avoid the race condition mentioned by @jxs as much as possible in the first place (it's not 100% avoidable), then maybe we don't need this special treatment. That said, I am not completely opposed to it. Just would like to avoid growing the API of |
Description
Behaviors can send events to a connection handler by emitting a
ToSwarm::NotifyHandler
event.Depending on the
PendingNotifyHandler::{One(_), Any(_)}
parameter, the swarm will then select either one specific, or any connection handler, that will receive the event.If the connection has closed in the mean time (either the one specific that is targeted, or all connections), the event gets silently discarded.
@jxs and I had a brief out-of-band discussion that we might want to inform the behavior about the event being dropped.
However, thinking about it now, I am not sure if the behavior even needs that info.
As already mentioned, the event is only dropped if the connection closed. The behavior is being informed about connections closing. So behaviors like
request-response
can simply track pending events for each connection, and based on that infer that a pending event/ request is discarded.That must be done anyway because it could be that the handler already consumed the event and then the connection closes.
@jxs is there a specific case where it's still problematic that the
NotifyHandler
event is silently dropped? And if so, how does that differ from the second scenario that I described, where the connection closes after the handler consumed the event?The text was updated successfully, but these errors were encountered: