Skip to content
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

fix: allow multiple connections via .startLocalProxy socket #366

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

jackwotherspoon
Copy link
Collaborator

@jackwotherspoon jackwotherspoon commented Jun 21, 2024

The .startLocalProxy method of starting a local Unix socket
to connect over used .once which was an oversight. This only
allows a single connection via the socket. For a connection pool
to leverage several connections at once we should use .on.

Tested using Prisma's connection_limit query argument.
Using .once only works with connection_limit=1 while using
.on allows for connection_limit=2 etc.

Fixes #349

@jackwotherspoon jackwotherspoon self-assigned this Jun 21, 2024
@jackwotherspoon jackwotherspoon requested a review from a team as a code owner June 21, 2024 02:03
@jackwotherspoon
Copy link
Collaborator Author

jackwotherspoon commented Jun 21, 2024

Tested this on a local setup with a variation of https://github.com/janpio/21604/tree/main which prints the Prisma metrics.
The metrics showcase that indeed more than 1 connection is being created via the connection pool when used with new approach.

When setting connection_limit=3 we can see 3 connections were opened at once...

{
      key: 'prisma_pool_connections_opened_total',
      labels: {},
      value: 3,
      description: 'The total number of pool connections opened'
}

Copy link
Collaborator

@hessjcg hessjcg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jackwotherspoon jackwotherspoon merged commit cce7aad into main Jun 21, 2024
22 checks passed
@jackwotherspoon jackwotherspoon deleted the fix-unix-sockets branch June 21, 2024 18:49
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.

Why does the Connector handle "connection" event with a single-call handler?
2 participants