Skip to content

Account for buffered events in dispatchers #312

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

Closed
wants to merge 1 commit into from

Conversation

stefanc18
Copy link

I updated the demand & partition dispatchers to account for the buffered events by adding an additional buffer_size parameter to the ask function. Therefore, if there are events in the buffer, they will be asked for. This solves the issue that happens when the producer buffers some events (because there are no consumers available), and then the consumers come back live. Previously the buffered events weren't sent because they were considered "already sent". Refer to the issue for the details of how the behavior reproduced: #311

dispatcher_callback(:ask, [counter, from, dispatcher_state], stage)
%{dispatcher_state: dispatcher_state, buffer: buffer} = stage
buffer_size = Buffer.estimate_size(buffer)
dispatcher_callback(:ask, [counter, buffer_size, from, dispatcher_state], stage)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if instead we should subtract the buffer size from the counter and only ask if the counter is more than zero?

@josevalim josevalim closed this in ab7bd85 Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants