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

3.x: Fix Flowable.groupBy cancellation/cleanup/eviction race hangs #6979

Merged
merged 1 commit into from
May 13, 2020

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented May 11, 2020

This PR fixes three additional race conditions from #6974 (comment)

  1. When a cancellation arrived asynchronously to a group, the drain loop quit and left unconsumed items in the queue and thus prevented the replenishment from the main upstream. Fix: change the drain loop to always clean & replenish upon seeing a canceled state.

  2. When a cancellation was detected just after the drain loop has polled from the queue, that polled item was ignored and not replenished. Fix: Include the non-empty polled item in the replenishment count upon cancellation.

  3. When a cancellation happened concurrently with an eviction, both could end up decrementing the group counter into an invalid (negative) number, preventing the operator to function properly. Fix: make sure group removal accounting happens at most once.

Fixes: #6974

@codecov
Copy link

codecov bot commented May 11, 2020

Codecov Report

Merging #6979 into 3.x will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##                3.x    #6979   +/-   ##
=========================================
  Coverage     99.61%   99.61%           
  Complexity     6670     6670           
=========================================
  Files           742      742           
  Lines         47254    47270   +16     
  Branches       6371     6375    +4     
=========================================
+ Hits          47071    47088   +17     
  Misses           61       61           
+ Partials        122      121    -1     
Impacted Files Coverage Δ Complexity Δ
...3/internal/operators/flowable/FlowableGroupBy.java 99.70% <100.00%> (+0.32%) 3.00 <0.00> (ø)
...xjava3/internal/observers/FutureMultiObserver.java 96.61% <0.00%> (-3.39%) 27.00% <0.00%> (-1.00%)
...eactivex/rxjava3/processors/BehaviorProcessor.java 97.48% <0.00%> (-2.52%) 50.00% <0.00%> (ø%)
...3/internal/operators/flowable/FlowablePublish.java 98.01% <0.00%> (-1.99%) 17.00% <0.00%> (-1.00%)
...tivex/rxjava3/internal/jdk8/ParallelCollector.java 91.74% <0.00%> (-1.84%) 2.00% <0.00%> (ø%)
...nternal/operators/parallel/ParallelSortedJoin.java 98.49% <0.00%> (-1.51%) 2.00% <0.00%> (ø%)
...ternal/operators/completable/CompletableMerge.java 97.29% <0.00%> (-1.36%) 2.00% <0.00%> (ø%)
...rnal/operators/observable/ObservableObserveOn.java 98.69% <0.00%> (-1.31%) 3.00% <0.00%> (ø%)
...ternal/operators/observable/ObservableFlatMap.java 98.22% <0.00%> (-1.07%) 3.00% <0.00%> (ø%)
...a3/internal/operators/flowable/FlowableReplay.java 98.92% <0.00%> (-0.86%) 21.00% <0.00%> (ø%)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb58c59...4065c0c. Read the comment docs.

@akarnokd akarnokd merged commit 5c26064 into ReactiveX:3.x May 13, 2020
@akarnokd akarnokd deleted the GroupByEvictionFix0511 branch May 13, 2020 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.0.3 - Hangs when using combination of flatMap and publish
1 participant