Skip to content

fix(connection): make named channels node-local#526

Open
smartinio wants to merge 3 commits intoelixir-grpc:masterfrom
smartinio:named-channel-cluster-fix
Open

fix(connection): make named channels node-local#526
smartinio wants to merge 3 commits intoelixir-grpc:masterfrom
smartinio:named-channel-cluster-fix

Conversation

@smartinio
Copy link
Copy Markdown

Problem

Named channels are currently registered with :global, which makes them effectively cluster-global across connected BEAM nodes.

In distributed deployments, this results in:

  1. One node creates the named channel registration
  2. Another node trying to connect the same named channel sees :already_started, then fails to resolve the channel locally and returns {:error, :no_connection}.

Root cause

GRPC.Client.Connection registers named channels globally via :global, but the selected channel state is still read from node-local :persistent_term. I.e. registration is shared across nodes, while channel state is not.

Fix

Scope named channels to the current BEAM node instead of sharing them across connected nodes.

  • Start a node-local Registry for client connections
  • Register named channels through that Registry instead of :global
  • Update connection tests to look up the node-local registration

Test plan

  • Added regression test that verifies two connected peer nodes don't conflict on the same name
  • Added a small shim for :peer to pass OTP24 interop tests, since :peer is an OTP25+ module

Comment thread grpc/lib/grpc/client/connection.ex Outdated
Co-authored-by: Adriano Santos <solid.sistemas@gmail.com>
@smartinio smartinio requested a review from sleipnir April 23, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants