Skip to content

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

Merged
sleipnir merged 7 commits into
elixir-grpc:masterfrom
smartinio:named-channel-cluster-fix
May 13, 2026
Merged

fix(connection): make named channels node-local#526
sleipnir merged 7 commits into
elixir-grpc:masterfrom
smartinio:named-channel-cluster-fix

Conversation

@smartinio
Copy link
Copy Markdown
Contributor

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
@sleipnir
Copy link
Copy Markdown
Collaborator

sleipnir commented Apr 29, 2026

@polvalente Would you also like to take a look here, or can we continue?

@smartinio
Copy link
Copy Markdown
Contributor Author

@sleipnir @polvalente Hi, this has been approved for 2 weeks now. Any chance we could get it merged? No rush, just making sure it's not forgotten.

@sleipnir sleipnir merged commit b4e4855 into elixir-grpc:master May 13, 2026
7 checks passed
@sleipnir
Copy link
Copy Markdown
Collaborator

@sleipnir @polvalente Hi, this has been approved for 2 weeks now. Any chance we could get it merged? No rush, just making sure it's not forgotten.

No, we haven't forgotten about you.

@sleipnir
Copy link
Copy Markdown
Collaborator

@smartinio I've done the merge, but we need to analyze other PRs before releasing a new version in hex.

@smartinio
Copy link
Copy Markdown
Contributor Author

@sleipnir Thanks. No rush, we cannot install the hex version until #519 is released. We're currently running that branch in production.

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