GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 3.x: Fix groupBy not canceling upstream due to group abandonment by akarnokd · Pull Request #6642 · ReactiveX/RxJava

Conversation

@akarnokd

@akarnokd akarnokd commented Aug 29, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This PR fixes the issue when a group is not subscribed to, the upstream may never cancel due to seemingly open groups.

The fix is a tradeoff with group abandonment and possible excessive group re-creation so that elements are not lost in case the groups do get subscribed to a bit later. Therefore, the groups should be subscribed to immediately and synchronously:

Observable.range(1, 1000)
.groupBy(v -> v % 10)
.flatMap(v -> {
    System.out.println("New group: " + v.getKey());
    return v;
})
.subscribe();

Observable.range(1, 1000)
.groupBy(v -> v % 10)
.flatMap(v -> {
    System.out.println("New group: " + v.getKey());
    return v.observeOn(Schedulers.io()); //  <-------------------------------- OK
})
.blockingSubscribe();

Consequently, the following setups will result in constant group recreations:

Observable.range(1, 1000)
.groupBy(v -> v % 10)
.observeOn(Schedulers.io()) // <------------------------------------- TROUBLE
.flatMap(v -> {
    System.out.println("New group: " + v.getKey());
    return v;
})
.blockingSubscribe();

Observable.range(1, 1000)
.groupBy(v -> v % 10)
.flatMap(v -> {
    System.out.println("New group: " + v.getKey());
    return v.subscribeOn(Schedulers.io()); // <----------------------- TROUBLE
})
.blockingSubscribe();

For the subscribeOn "trouble", since groups were essentially unicast subjects/processors, subscribeOn had no practical use on them and instead observeOn should be used to move the observation of the group's items to the desired thread.

Resolves #6596

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@akarnokd
3.x: Fix groupBy not canceling upstream due to group abandonment
00cc176
@akarnokd akarnokd added Shortcoming 3.x labels Aug 29, 2019
@akarnokd akarnokd added this to the 3.0 milestone Aug 29, 2019
akarnokd added 3 commits August 29, 2019 14:08
@akarnokd
Add codecov retry on connection refused
02f8950
@akarnokd
Retry connrefused
29fc01a
@akarnokd
Connrefused not supported?
a532b6e
@codecov

codecov Bot commented Aug 29, 2019

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (3.x@c9204b5). Click here to learn what that means.
The diff coverage is 89.58%.

Impacted file tree graph

@@          Coverage Diff           @@
##             3.x    #6642   +/-   ##
======================================
  Coverage       ?   98.11%           
  Complexity     ?     6192           
======================================
  Files          ?      678           
  Lines          ?    44721           
  Branches       ?     6176           
======================================
  Hits           ?    43879           
  Misses         ?      298           
  Partials       ?      544
Impacted Files Coverage Δ Complexity Δ
.../main/java/io/reactivex/rxjava3/core/Flowable.java 100% <ø> (ø) 561 <0> (?)
...ain/java/io/reactivex/rxjava3/core/Observable.java 100% <ø> (ø) 537 <0> (?)
...3/internal/operators/flowable/FlowableGroupBy.java 95.2% <88.46%> (ø) 3 <0> (?)
...ternal/operators/observable/ObservableGroupBy.java 95.5% <90.9%> (ø) 2 <0> (?)

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 c9204b5...a532b6e. Read the comment docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vanniktech
vanniktech approved these changes Aug 29, 2019
View reviewed changes
@akarnokd
akarnokd merged commit 9a36930 into ReactiveX:3.x Aug 29, 2019
@akarnokd
akarnokd deleted the GroupByFix3x branch August 29, 2019 14:33
@akarnokd akarnokd mentioned this pull request Aug 29, 2019
What's Different in 3.x (tracking issue) #6515
Closed
70 tasks done
@akarnokd akarnokd mentioned this pull request Sep 11, 2019
3.0.0-RC3 release preparations #6649
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@vanniktech vanniktech vanniktech approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

3.x Shortcoming

Projects

None yet

Milestone

3.0

Development

Successfully merging this pull request may close these issues.

3.x: groupBy may never cancel the upstream if the group is dropped

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@akarnokd @vanniktech
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.