-
Notifications
You must be signed in to change notification settings - Fork 228
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
Synchronize calls to StreamObserver methods #2934
Synchronize calls to StreamObserver methods #2934
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if concurrent call happens? Will client missed one call? Or it messed up the order?
@junkaixue If concurrent call happens, one of the messages will fail to send and the state transition will result in ERROR. When multiple state transition threads call
|
Just want to make sure the behavior is right. Because once the synchronization happens, not sure whether the locking can lead any ordering problem. |
…r or onComplete can't be called again.
@junkaixue I have opted to use lockRegistry to synchronize calls to onNext, onError, and onComplete in addition to moving modifications and gets to _observerMap and _reverseObserverMap into the related critical sections. This will ensure that onNext is never called after a connection is closed and we never attempt to close a connection more than once. It is okay if one thread closes connection before another thread sends the StateChangeRequest. In this case, the message will not be sent and the state transition will not be processed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logics looks good. But make sure the lock retrieve logic is not get or create. Then the lock will come back.
The retrieve lock logic is getOrCreate. This is okay because we remove the lock in Same for It is unlikely that |
All the failing tests are flaky: This PR is ready to be merged. Final Commit Message:
|
Issues
Tests
NA
Changes that Break Backward Compatibility (Optional)
NA
Documentation (Optional)
NA
Commits
Code Quality
(helix-style-intellij.xml if IntelliJ IDE is used)