-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Fix zip race condition #778
Conversation
ItemObserver onNext might not acquire the write lock due to an onCompleted being handled by another thread. When handling onCompleted, the ItemObserver does not check for any values that are ready to be emitted, which might cause OperationZip to never emit OnNext or OnCompleted.
RxJava-pull-requests #692 FAILURE |
Not sure why it failed, since it passes locally and zip is not used in that test case. Is there a way to re-trigger the build? |
Nice catch. Basically, you need something like T1:onNext, (T1: onCompleted, T2: onNext) T2: onCompleted where T1 onCompleted wins the lock over T2: onNext, then T2 onCompleted just doens't do anything as the queues aren't empty. I confirm your fix solves this issue. We have a few unreliable tests and rerunning might not produce success. Closing and reopening the PR might trigger a run, but I'm not sure. |
@benjchristensen any idea on how to re-trigger CI build? |
Only way I know how is updating the PR such as with a new commit :-( It's quite annoying that way. |
Is it possible to demonstrate the race with a unit test, perhaps using latches to cause the necessary race? Reason is that the |
Unfortunately it's an internal race between acquiring the read lock and trying to acquire the write lock. I don't have any good ideas on how to test it without coupling it to the specific implementation. |
RxJava-pull-requests #693 FAILURE |
LinkedList permits null values, no need for NULL_SENTINEL.
RxJava-pull-requests #694 SUCCESS |
Fix zip race condition
The ItemObserver collection logic needs to run in both the OnNext and OnCompleted handlers.
Otherwise, you might have values waiting to be emitted and without seeing an OnCompleted. I couldn't think of an easy unit test for this, it actually took a while to narrow down the example.
The only way I could reproduce it on my machine was to use Hystrix and it happens somewhat sporadically (10-50 iterations).