Skip to content
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

Fix mixnode HOL blocking #530

Closed
wants to merge 5 commits into from
Closed

Conversation

youngjoon-lee
Copy link
Contributor

@youngjoon-lee youngjoon-lee commented Nov 13, 2023

Closes #526

  • b7a5ac7: fixed the mixnode HOL blocking issue where the mixnode process is blocked if only one of packets is not forwarded in the reasonable amount of time.
    • Instead of having a single task who forwards all packets sequentially, spawn a separate task for each destination connection. IIRC, this is the way that we had previously discussed, but we missed to implemented it.
  • f4a40b9: refactored into sub-files.
  • 8c1d959: comments (sorry for putting this commit at the last).

TODO: #529 and #531

@youngjoon-lee youngjoon-lee added bug Something isn't working mixnet labels Nov 13, 2023
@youngjoon-lee youngjoon-lee added this to the Mixnet milestone Nov 13, 2023
@youngjoon-lee youngjoon-lee self-assigned this Nov 13, 2023
@youngjoon-lee youngjoon-lee linked an issue Nov 13, 2023 that may be closed by this pull request
@youngjoon-lee youngjoon-lee marked this pull request as ready for review November 13, 2023 10:04
Comment on lines +36 to +40
if let Entry::Vacant(entry) = self.forwarders.entry(packet.target) {
entry.insert(Forwarder::new(packet.target, self.config));
}

let forwarder = self.forwarders.get_mut(&packet.target).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: self.forwarders.entry(...).or_insert_with(|| ...).schedule(packet.body)

}
}

fn handle_retry(&self, mut pkt: Packet) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we remove retries?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I forgot to mention about this in the PR. Actually, we're not removing retry. I changed the retry mechanism little bit in this case.

Previously, we keep a retry_count for each packet, and if it still fails after max_retries, we drop the packet.

But, in this PR, I simplifed the retry mechanism from per-packet to per-connection, since a mixnode must always maintain connections with the next mix layer. If we fail to send a packet to a certain connection, we push the packet back to the queue and try to re-establish the connection. So, it's reconnect precisely (rather than retry).
(Actually, our previous retry implementation had something wrong. It didn't re-establish the connection when the write call is failed with IO error. Then, the retry won't help.)

Also, I removed the max_retries parameter in this PR because the mixnode has to try its best to re-establish connections with the next layer. This will make the message queue (UnboundedChannel) very big if the retry keeps failing, but I think it's the common case that can happen in other parts that use queues. Maybe, we can revive the max_retries parameter, and drop/block all messages for the dead connection if the reconnect keeps failing.

p.s.
I found that I removed the exponential backoff. I'll revive it.

Copy link
Contributor

@zeegomo zeegomo Nov 22, 2023

Choose a reason for hiding this comment

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

Makes sense, after all all packets in a connection will likely suffer the same fate

@youngjoon-lee
Copy link
Contributor Author

@zeegomo Please don't review this PR. I'm closing this because I found that there is a similar part in the mixclient, which can be refactored similarily using the connection pool that I implemented in this PR. I'm gonna create a common crate connpool and use it for both mixnode and mixclient. That would simplify lots of things: retry, concurrency, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mixnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mixnode HOL blocking
3 participants