minogrpc: deadlock in non tree based routing #170
Labels
bug
Something isn't working
mod/mino/grpc
About the Mino/grpc module
wontfix
This will not be worked on
This came up while trying out RABYT. Consider a scenario where we have 15 nodes (0-14).
Node 0 broadcasts a message to the other 14 nodes. Some of them are via intermediate nodes so they take 2 hops. Now each node on receiving the message from Node0 tries to send a response back to it. Let's assume the routing to Node0 is via Node9. Here's how a deadlock can occur:
Node0 holds an
RLock
onsession.parentsLock
while it tries to broadcast a message. At the same time, Node9 tries to establish a connection to Node0. When the Stream GRPC handler is invoked on the server side it tries to acquire a write lock on session.parentsLock in the call tosess.Listen()
and blocks. Eventually both Node0 and Node9 aren't able to make progress. Since other nodes depend on Node9 to route message to Node0 none of the nodes are able to continue.Possible workaround:
session.RecvPacket
andsession.Send
can avoid holding the RLock by copying the references to values ofs.parents
in a local slice. The risk then would be trying to use a relay that has been closed whensession.Listen
exits. Maybe we can have a per parent lock instead to avoid it as suggested by @cache-nezThe text was updated successfully, but these errors were encountered: