serverless-pg icon indicating copy to clipboard operation
serverless-pg copied to clipboard

Possibility to only terminate connections from the "serverless" services/clients.

Open santriseus opened this issue 1 year ago • 2 comments

Hi, It is not an issue but more like a question/feature suggestion. After a quick look at library I understand that it terminates any backend connection according to strategy, regardless if it was created by the serverless-pg library or not. Do I understand it right? In this case it can terminate connections from the different clients in long-running containers or servers. For sure, in ideal world every client should have resilience and recover, but there could be some issues with it. Is it technically possible to introduce something like 'client name' in pg client and forward it to tables we use for monitoring processes, and then introduce optional filtering by this client id when trying to kill a process?

santriseus avatar Sep 20 '22 07:09 santriseus

Yes, that's correct. I have never thought about this use case, but it seems a very useful addition indeed.

PostgreSQL has the application_name option in the connection string, and I think pg_stat_activity has it as a column: https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW

I will try to see how this could be implemented.

One question that I have in mind:

  • Should this be implemented by default?

MatteoGioioso avatar Sep 25 '22 06:09 MatteoGioioso

I have added this functionality in the new major version (2)

MatteoGioioso avatar Oct 04 '22 04:10 MatteoGioioso