pg_cancel_backend and pg_terminate_backend - Mailing list pgsql-admin

From Wetmore, Matthew (CTR)
Subject pg_cancel_backend and pg_terminate_backend
Date
Msg-id 83b2ee4970954aebb6dbe7d8f5f6e87b@express-scripts.com
Whole thread Raw
In response to pg_cancel_backend and pg_terminate_backend  (Wells Oliver <wells.oliver@gmail.com>)
Responses Re: pg_cancel_backend and pg_terminate_backend  (Wells Oliver <wells.oliver@gmail.com>)
Re: pg_cancel_backend and pg_terminate_backend  (Rui DeSousa <rui@crazybean.net>)
List pgsql-admin

pg_cancel_backend()

A function which cancels a backend's current query

 

pg_terminate_backend()

A function which instructs a backend to terminate

 

From: Wells Oliver <wells.oliver@gmail.com>
Sent: Wednesday, April 19, 2023 2:42 PM
To: pgsql-admin <pgsql-admin@postgresql.org>
Subject: [EXTERNAL] pg_cancel_backend and pg_terminate_backend

 

I usually prefer pg_cancel_backend because it seems.. nicer, but lately I've had a troublesome user who leaves transactions open and I've scripted up a call to pg_terminate_backend after 60 minutes in an idle transaction. It works well.

 

Question: is there any server impact beyond that user's transaction when calling pg_terminate_backend? I feel like there _used_ to be, maybe in PG9, where I recall maybe seeing a server disconnect or something when using terminate.

 

Just curious about this approach. Thanks.

 

--

pgsql-admin by date:

Previous
From: MichaelDBA
Date:
Subject: Re: pg_cancel_backend and pg_terminate_backend
Next
From: "Wetmore, Matthew (CTR)"
Date:
Subject: pg_cancel_backend and pg_terminate_backend