-
Notifications
You must be signed in to change notification settings - Fork 4k
core: fix ConnectivityStateManager is already disabled bug #3288
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
Conversation
4d2d151 to
d37a39a
Compare
|
Jenkins, retest this please |
| // When ConnectivityStateManager is already disabled, then channel shutdown is called. | ||
| // Keep state being null. | ||
| return; | ||
| } |
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.
ConnectivityStateManager should not discriminate states based on the assumption of who calls gotoState(), because the manager may be used in other cases where the assumption may not hold.
I think the issue is that ManagedChannelImpl.shutdown() calls gotoState() when the manager is already disabled. To fix this immediate issue, we can add an isDisabled() to the manager and avoid calling gotoState() if it returns true.
ec85979 to
748cb81
Compare
| createChannel(new FakeNameResolverFactory(false), NO_INTERCEPTOR); | ||
| assertEquals(ConnectivityState.IDLE, channel.getState(false)); | ||
| helper.updatePicker(mockPicker); | ||
|
|
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.
Because gotoState() is called in ChannelExecutor, which catches all exceptions, this shutdown() will not throw even without the fix.
Perhaps we can add an assert false in ChannelExecutor's exception handling block, to actually break test (assuming tests all have assertion enabled).
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.
Applications may also turn on -ea, then the entire application may fail if any runtime exception is thrown in ChannelExecutor's runnables.
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 about we run unit tests with a -Dtestgrpc=true argument, and in ChannelExecutor's exception handling block we check if testgrpc is true, if it is we assert false?
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.
The decision for ChannelExecutor to catch instead of throwing is questionable. I did it because ChannelExecutor may run in any thread, e.g., network thread, and I didn't feel comfortable to let random code, e.g., LoadBalancer to throw in network thread. But maybe it's better to just throw? @ejona86 WDYT?
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.
Filed #3293 tracking the ChannelExecutor exception handling.
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.
I'd much rather defer the question; I don't think the user-visible exception handling behavior should be determined by the unit tests. I do think it tends to make sense to catch and log the exception, since propagating the exception will probably only cause additional failures and we know the current stack does not depend on the result of the call (since the execution is not guaranteed to be complete when drain returns.)
You could inject an exception handler or some such, though. We do know that none of the tests should cause an exception in the channel executor.
|
Jenkins, retest this please |
Fix bug found by internal user