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

Continue polling clients in priority queue if the top is not ready #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michael-disalvo
Copy link

The fair queue iterator implementation returns Poll::Pending when there may be other streams in the priority queue that are ready. Instead of returning after checking only the top stream, continue checking until a stream that returns Poll::Ready is found, or all streams have returned Poll::Pending and will resubmit themselves to the priority queue when they are ready.

I had an issue that can be summarized as the following: I had a server with a pull socket, and two clients connecting with push sockets. One client was fast and sent a message every second. The other client was slow and sent a message every 5 seconds. I expected the server to receiver 5 messages from the fast client, and then a single message from the slow client, and that this would repeat. I observed the eventually, the server would receive only single message from the fast client until a single message from the slow client was received. I debugged this and realized that when the server's fair-queue contained both clients, only the slow client would get polled, leaving the fast client in the queue, even though it was ready.

To reproduce this, I created a demo repo at https://github.com/michael-disalvo/zeromq-demo. Clone it, and run 3 processes:

  • cargo run --bin server
  • cargo run --bin client -- -s 1 -m fast
  • cargo run --bin client -- -s 5 -m slow

The server will print out when it receives each message. At first, every second a message will be received from the fast client. Eventually, it will get stuck and the server will receiver a message from the fast client only every 5 seconds.

@michael-disalvo michael-disalvo marked this pull request as ready for review February 19, 2025 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant