I am writing a replay system for my simulator of an asynchronous distributed system, and I'm having a problem with an unbounded crossbeam channel.
During a run, each node creates a file of trace records. If I detect a bug, I replay the received messages from that file. It's mostly working, but there is one place where the replayed messages sometimes get lost. Below is a simplified version of the send loop. The actual code sends messages to other receivers; they never fail.
Here trace_lines is a Lines<BufReader<File>> iterator. At this point I've created the channel and got the transmit and receive parts to the right places. The thread::sleep makes sure the thread doesn't exit before the messages are delivered.
There's nothing obviously wrong here, but it is quite clear that you did not post the real code considering you somehow ended up with a sleep inside a match next to one of the arms. Perhaps the issue will be clear if you post the actual code with the issue?
I get the same value for port on runs that succeed and those that fail.
The receive side is pretty much what's in the original example. Only the names have been changed to keep me from getting yelled at.
I've clearly got some sort of message order race, because it works on some runs and not others. I just can't see what it could be. The printlns seem to show that things are happening in the right order, e.g., waiting for the message before it is sent.
Good thought, @steffahn. That channel is set up in single threaded code before the replay code runs, so it should be OK. Still, I'd like to check, but I don't know how. Printing with {:?} gives Sender { .. }.