-
Notifications
You must be signed in to change notification settings - Fork 117
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(data): Resolve orchestrator transition threading issues. #2551
Conversation
Issue #2458 is also referencing this same problem. |
🤔 There are definitely some good improvements here - it's easy to see how the prior direct invocation of What about wrapping the contents of the completable in a lock, such that we can guarantee that no threads can interleave between Another option would be to use a single-threaded scheduler instead of |
…ng' into tjroach/fix-orchestrator-threading
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #2551 +/- ##
==========================================
+ Coverage 40.79% 40.82% +0.02%
==========================================
Files 873 873
Lines 27597 27621 +24
Branches 3877 3878 +1
==========================================
+ Hits 11258 11276 +18
- Misses 15135 15139 +4
- Partials 1204 1206 +2 |
Issue #1010 might also be referencing same problem |
Issue #, if available:
aws-amplify/amplify-flutter#3017
Description of changes:
This PR intends to fix the crash caused by the UnicastSubject "buffer" in the SubscriptionProcessor being subscribed to more than once. I believe there were 2 root causes to this.
startApiSync
andstopApiSync
rather than use the transitionTo methods. The transitionTo methods read the current state, and ignore calls if the current state equals the requested state. I believe the crash was due tostartApiSync
being called multiple times, and through a race condition, there was a scenario that could allow the UnicastSubject to receive more than 1 subscription.stopApiSync
is called, the completable that is started instartApiSync
does not stop by simply clearing the disposable. As a result, a call to start/stop/start could still result in a single buffer being subscribed to more than once. A check to stop additional processing was added in the startApiSync completable, if the disposable was cleared.Lastly, I refactored the
currentState.set
calls to only be made inside the transitionTo api methods and added a lock for thread safety.How did you test these changes?
(Please add a line here how the changes were tested)
Documentation update required?
General Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.