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 race (out of order) in flushing topics (wrong state is stored in changelog) #112

Merged
merged 4 commits into from
Feb 27, 2021

Conversation

trauter
Copy link
Contributor

@trauter trauter commented Feb 25, 2021

This PR fixes a race condition in writing messages to topics that resulted in a violation of the ordering guarantee (especially changelog topics).

What happened before:
The producer buffer is filled with messages.
_handle_pending is taking one message from the buffer at a time (Participant 1).
If the buffer grows flush_atmost is called which itself starts taking messages from the buffer and sends them (Participant 2).

In rare cases, both participants popped message (e.g. MSG1, then MSG2), but the messages are written in reverse order (e.g. MSG2, then MSG1) to the topic.
In case of changelog topics, this results in wrong states if both messages have the same key.

The fix:
Basically, flush simply waits until the buffer is empty.

trauter and others added 4 commits February 25, 2021 11:41
since the flush functions now simply
wait for the main producer loop to send the messages, we have to
mock this behaviour in the tests, too
@patkivikram patkivikram merged commit a841a0e into faust-streaming:master Feb 27, 2021
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.

2 participants