-
Notifications
You must be signed in to change notification settings - Fork 60
Description
Description
In go-tarantool, there is an option to pass a Notify channel in connection options to receive connection-related events (connect / disconnect, etc.).
This is useful, for example, to build client-side metrics based on connection lifecycle events.
Relevant code
Notify option handling in single connection:
https://github.com/tarantool/go-tarantool/blob/v2.4.1/connection.go#L323
This mechanism works correctly when using a direct Connection.
However, after migrating to connection_pool, I noticed that all connection-related metrics based on Notify stopped working.
During debugging, I found the following behavior:
- Events are still being written, but not into the user-provided Notify channel.
- On the receiving side, the user-provided channel remains silent (no events).
The root cause appears to be that the pool implementation overrides the Notify channel provided by the user.
Specifically
In connection_pool.go, the Notify field from user options is replaced with an internally created channel:
https://github.com/tarantool/go-tarantool/blob/v2.4.1/pool/connection_pool.go#L1309
This internal channel is created inside the pool:
https://github.com/tarantool/go-tarantool/blob/v2.4.1/pool/connection_pool.go#L143
As a result
- The original user-provided Notify channel loses all writers.
- The newly created internal Notify channel has no readers outside the pool.
- Connection events are effectively lost from the user’s perspective.
This behavior is not obvious from the API and silently breaks setups that rely on Notify for observability when switching from a single connection to a pool.
Expected behavior
One of the following (or an explicit documented alternative):
- Preserve and forward events to the user-provided Notify channel.
- Fan-out events to both internal and user-provided channels.
- Or clearly document that Notify is ignored / replaced when using connection_pool, and provide another supported way to observe connection events.
At the moment, the current behavior leads to lost events without any warning.