Fix: record tracker does not support concurrent event batch removal #431
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.
This PR aims to fix the issue #423.
The record tracker uses
ConcurrentNavigableMap
iterators.These iterators are Weakly-Consistent iterators.
That means that a thread will not see reflected changes made by another concurrent thread.
Therefore, events can be removed multiple times and the total number of event is not accurate and can become a negative number.
The idea of this fix is to first make sure that the total number of event never become a negative number anymore and given the strategy, we don't need to clean the event batches in parallel. Only one thread needs do the job at some point.
Another approach would be to use the batch input parameter of the function
removeAckedEventBatches
, but I did not want to change the design too much.