Skip to content

Fix an unsubscribe race in EventLoopWorker #3868

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

Merged
merged 1 commit into from
Apr 20, 2016

Conversation

zsxwing
Copy link
Member

@zsxwing zsxwing commented Apr 20, 2016

There is an unsubscribe race condition similar to #3842 in CachedThreadScheduler.EventLoopWorker and EventLoopsScheduler.EventLoopWorker. Image the following execution order:

Execution Order thread 1 thread 2
1 submit task A
2 submit task B
3 unsubscribe Worker
4 unsubscribe task A
5 task A won't run as it's unsubscribed
6 run task B
7 unsubscribe task B

So task B will run but its previous task A will be skipped.

This PR adds a check before running an action and moves workerUnderConcurrentUnsubscribeShouldNotAllowLaterTasksToRunDueToUnsubscriptionRace to AbstractSchedulerConcurrencyTests to test all concurrent schedulers.

@akarnokd
Copy link
Member

👍

@zsxwing zsxwing merged commit 8af2bc9 into ReactiveX:1.x Apr 20, 2016
@zsxwing zsxwing deleted the event-loop-race branch April 20, 2016 17:03
@davidmoten
Copy link
Collaborator

👍 Thanks @zsxwing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants