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

Listen for postgres events using owner connection url #1558

Open
6 tasks
jhg03a opened this issue Nov 29, 2021 · 2 comments
Open
6 tasks

Listen for postgres events using owner connection url #1558

jhg03a opened this issue Nov 29, 2021 · 2 comments
Labels
🔁 revisit-in-v5 Not happy with this behaviour, but changing it is a breaking change.

Comments

@jhg03a
Copy link

jhg03a commented Nov 29, 2021

Feature description

I'd like the pg client that's handling the notification subscription to use the owner connection string instead of the client connection string.

Motivating example

In my environment I use pgbouncer in transaction pool mode by default. This unfortunately silently eats all notifications coming from postgres as there's not a session to send them back to. I do separate my postgres client connection string from the owner connection string to limit superuser exposure. This enables me to still keep the more optimal transaction pooling of pgbouncer for routine client queries/mutations. The present workaround is to either use session pooling in pgbouncer or drop it entirely unfortunately.

Breaking changes

For users who don't separate the owner connection string, there's no difference. For users that do, it might change behavioral expectations on that owner client connection to be short lived.

Supporting development

I [tick all that apply]:

  • am interested in building this feature myself
  • am interested in collaborating on building this feature
  • am willing to help testing this feature before it's released
  • am willing to write a test-driven test suite for this feature (before it exists)
  • am a Graphile sponsor ❤️
  • have an active support or consultancy contract with Graphile
@benjie
Copy link
Member

benjie commented Dec 2, 2021

I think having the option to do this kind of thing via a dedicated client makes sense, but it's not clear to me that ownerConnectionString is the right client for this. This might also overlap with requirements for subscriptions on replicas via readOnlyConnectionString. More thought required 🤔

@benjie
Copy link
Member

benjie commented Dec 8, 2021

I think to do this right what we actually want is a "listenClient" that gets passed all the way through PostGraphile - this way the pg-pubsub listeners can use it as well as the introspection plugin. The issue is if the client disconnects. We don't want to pass a "listenPool" because then we'd have to get two separate connections from it (one for introspection, one for pg-pubsub)... So really we want a managed listener that manages its own client but is shared by the whole stack. That's a bit of an ask for v4...

In the mean time, maybe you can set up an external listener for these events and then patch those events back into the relevant pgClient using pgClient.emit(...)?

@benjie benjie added the 🔁 revisit-in-v5 Not happy with this behaviour, but changing it is a breaking change. label Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔁 revisit-in-v5 Not happy with this behaviour, but changing it is a breaking change.
Projects
Status: 🐭 Shrew
Development

No branches or pull requests

2 participants