Runtime events consumer: don't parse dropped events#12062
Merged
kayceesrk merged 4 commits intoocaml:trunkfrom Mar 18, 2023
Merged
Runtime events consumer: don't parse dropped events#12062kayceesrk merged 4 commits intoocaml:trunkfrom
kayceesrk merged 4 commits intoocaml:trunkfrom
Conversation
sadiqj
reviewed
Mar 2, 2023
Contributor
sadiqj
left a comment
There was a problem hiding this comment.
This looks good @TheLortex , thanks for identifying and a fix.
Only one issue is I can't get the test to fail in the case where the fix isn't applied. Does it fail reliably for you?
Contributor
Author
Yes it does. Maybe try increasing the numbers in the two |
eccb7f9 to
99abe06
Compare
Contributor
Agreed, thanks for taking a look @Engil . Maybe it's just a quirk of my local setup. I think we're good to go. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the runtime events consumer library, there's a code path that handles the case when an event content is read, but in the meantime was overwrote by the producer. In that case, it calls the the
lost_eventscallback if it exists, but then continues parsing the event with whatever data overwritten in the ring buffer, yielding incorrect values.This problem appeared when I used custom runtime events at a very high rate (700k/s). Indeed, at a low rate this code path is rarely taken.
The PR includes a reproduction test that spawns two domains, one emitting custom events at a high rate and one consuming them and checking that the associated value is expected (
0). If it's different, it means that the event payload was overwrote with a new event block (the expected zero value would then contain a header or timestamp value parsed as an integer).The proposed fix is the following:
continue(jump over event parsing) for all code paths as long as the event dropped condition is met:/* Check the message we've read hasn't been overwritten by the writer */ if (ring_head > cursor->current_positions[domain_num]) { ... + continue; }@Engil @sadiqj