Skip to content

Notify channel from user options is silently overridden in connection pool #513

@tulzke

Description

@tulzke

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions