-
Notifications
You must be signed in to change notification settings - Fork 157
Fix NettyChannelTracker race condition when tracking new channels #904
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
This update fixes an issue when `SimpleChannelPool` may invoke the `channelAcquired` method before the `channelCreated` method is called. Since it violates `NettyChannelTracker` contract, it may result in runtime failures.
See the following for details:
```
@startuml
T1 -> SimpleChannelPool: acquireHealthyFromPoolOrNew
activate SimpleChannelPool
SimpleChannelPool -> NettyChannelPool: connectChannel
activate NettyChannelPool
NettyChannelPool -> ChannelFuture: addListener
activate ChannelFuture
ChannelFuture --> NettyChannelPool:
deactivate ChannelFuture
NettyChannelPool --> SimpleChannelPool:
deactivate NettyChannelPool
T2 -> ChannelFuture: setSuccess
activate ChannelFuture
ChannelFuture -> ChannelFuture: done
activate ChannelFuture
ChannelFuture --> ChannelFuture:
deactivate ChannelFuture
SimpleChannelPool -> ChannelFuture: isDone
activate ChannelFuture
ChannelFuture --> SimpleChannelPool:
deactivate ChannelFuture
alt isDone case
SimpleChannelPool -> NettyChannelTracker: channelAcquired
activate NettyChannelTracker
NettyChannelTracker --> SimpleChannelPool:
deactivate NettyChannelTracker
end
SimpleChannelPool --> T1:
deactivate SimpleChannelPool
ChannelFuture -> NettyChannelTracker: channelCreated
activate NettyChannelTracker
NettyChannelTracker -> ChannelFuture:
deactivate NettyChannelTracker
ChannelFuture -> T2:
deactivate ChannelFuture
@enduml
```
just to be sure, this is about the old situation? |
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.
Looks good to me.
A couple of things:
- I wonder if we can reproduce the failures locally when metrics are turned on
- did we actually make the failures happen more often because the tracker is now thread safe after the previous fix attempts?
- If this works I like it to be backported to 4.2 and 4.1 but I can do that as well.
This is about the case that this change tries to fix. |
I tried setting up a simple case on local environment, but could not reproduce this. Given that this is effectively a race condition, it might be tricky to reproduce. Fortunately, we have some CI builds that may help us with this. |
This change did not seem to make a negative impact on my local environment, it will be verified further in CI builds. |
Since it fixes a race condition that may occur, it makes sense to backport it. |
Thanks 👍 |
…o4j#904) This update fixes an issue when `SimpleChannelPool` may invoke the `channelAcquired` method before the `channelCreated` method is called. Since it violates `NettyChannelTracker` contract, it may result in runtime failures. See the following for details: ``` @startuml T1 -> SimpleChannelPool: acquireHealthyFromPoolOrNew activate SimpleChannelPool SimpleChannelPool -> NettyChannelPool: connectChannel activate NettyChannelPool NettyChannelPool -> ChannelFuture: addListener activate ChannelFuture ChannelFuture --> NettyChannelPool: deactivate ChannelFuture NettyChannelPool --> SimpleChannelPool: deactivate NettyChannelPool T2 -> ChannelFuture: setSuccess activate ChannelFuture ChannelFuture -> ChannelFuture: done activate ChannelFuture ChannelFuture --> ChannelFuture: deactivate ChannelFuture SimpleChannelPool -> ChannelFuture: isDone activate ChannelFuture ChannelFuture --> SimpleChannelPool: deactivate ChannelFuture alt isDone case SimpleChannelPool -> NettyChannelTracker: channelAcquired activate NettyChannelTracker NettyChannelTracker --> SimpleChannelPool: deactivate NettyChannelTracker end SimpleChannelPool --> T1: deactivate SimpleChannelPool ChannelFuture -> NettyChannelTracker: channelCreated activate NettyChannelTracker NettyChannelTracker -> ChannelFuture: deactivate NettyChannelTracker ChannelFuture -> T2: deactivate ChannelFuture @enduml ```
…o4j#904) This update fixes an issue when `SimpleChannelPool` may invoke the `channelAcquired` method before the `channelCreated` method is called. Since it violates `NettyChannelTracker` contract, it may result in runtime failures. See the following for details: ``` @startuml T1 -> SimpleChannelPool: acquireHealthyFromPoolOrNew activate SimpleChannelPool SimpleChannelPool -> NettyChannelPool: connectChannel activate NettyChannelPool NettyChannelPool -> ChannelFuture: addListener activate ChannelFuture ChannelFuture --> NettyChannelPool: deactivate ChannelFuture NettyChannelPool --> SimpleChannelPool: deactivate NettyChannelPool T2 -> ChannelFuture: setSuccess activate ChannelFuture ChannelFuture -> ChannelFuture: done activate ChannelFuture ChannelFuture --> ChannelFuture: deactivate ChannelFuture SimpleChannelPool -> ChannelFuture: isDone activate ChannelFuture ChannelFuture --> SimpleChannelPool: deactivate ChannelFuture alt isDone case SimpleChannelPool -> NettyChannelTracker: channelAcquired activate NettyChannelTracker NettyChannelTracker --> SimpleChannelPool: deactivate NettyChannelTracker end SimpleChannelPool --> T1: deactivate SimpleChannelPool ChannelFuture -> NettyChannelTracker: channelCreated activate NettyChannelTracker NettyChannelTracker -> ChannelFuture: deactivate NettyChannelTracker ChannelFuture -> T2: deactivate ChannelFuture @enduml ```
…) (#905) This update fixes an issue when `SimpleChannelPool` may invoke the `channelAcquired` method before the `channelCreated` method is called. Since it violates `NettyChannelTracker` contract, it may result in runtime failures. See the following for details: ``` @startuml T1 -> SimpleChannelPool: acquireHealthyFromPoolOrNew activate SimpleChannelPool SimpleChannelPool -> NettyChannelPool: connectChannel activate NettyChannelPool NettyChannelPool -> ChannelFuture: addListener activate ChannelFuture ChannelFuture --> NettyChannelPool: deactivate ChannelFuture NettyChannelPool --> SimpleChannelPool: deactivate NettyChannelPool T2 -> ChannelFuture: setSuccess activate ChannelFuture ChannelFuture -> ChannelFuture: done activate ChannelFuture ChannelFuture --> ChannelFuture: deactivate ChannelFuture SimpleChannelPool -> ChannelFuture: isDone activate ChannelFuture ChannelFuture --> SimpleChannelPool: deactivate ChannelFuture alt isDone case SimpleChannelPool -> NettyChannelTracker: channelAcquired activate NettyChannelTracker NettyChannelTracker --> SimpleChannelPool: deactivate NettyChannelTracker end SimpleChannelPool --> T1: deactivate SimpleChannelPool ChannelFuture -> NettyChannelTracker: channelCreated activate NettyChannelTracker NettyChannelTracker -> ChannelFuture: deactivate NettyChannelTracker ChannelFuture -> T2: deactivate ChannelFuture @enduml ```
…) (#906) This update fixes an issue when `SimpleChannelPool` may invoke the `channelAcquired` method before the `channelCreated` method is called. Since it violates `NettyChannelTracker` contract, it may result in runtime failures. See the following for details: ``` @startuml T1 -> SimpleChannelPool: acquireHealthyFromPoolOrNew activate SimpleChannelPool SimpleChannelPool -> NettyChannelPool: connectChannel activate NettyChannelPool NettyChannelPool -> ChannelFuture: addListener activate ChannelFuture ChannelFuture --> NettyChannelPool: deactivate ChannelFuture NettyChannelPool --> SimpleChannelPool: deactivate NettyChannelPool T2 -> ChannelFuture: setSuccess activate ChannelFuture ChannelFuture -> ChannelFuture: done activate ChannelFuture ChannelFuture --> ChannelFuture: deactivate ChannelFuture SimpleChannelPool -> ChannelFuture: isDone activate ChannelFuture ChannelFuture --> SimpleChannelPool: deactivate ChannelFuture alt isDone case SimpleChannelPool -> NettyChannelTracker: channelAcquired activate NettyChannelTracker NettyChannelTracker --> SimpleChannelPool: deactivate NettyChannelTracker end SimpleChannelPool --> T1: deactivate SimpleChannelPool ChannelFuture -> NettyChannelTracker: channelCreated activate NettyChannelTracker NettyChannelTracker -> ChannelFuture: deactivate NettyChannelTracker ChannelFuture -> T2: deactivate ChannelFuture @enduml ```
This update fixes an issue when
SimpleChannelPoolmay invoke thechannelAcquiredmethod before thechannelCreatedmethod is called. Since it violatesNettyChannelTrackercontract, it may result in runtime failures.See the following for details: