pg_cancel_backend and pg_terminate_backend

From: "Wetmore, Matthew (CTR)" <Matthew(dot)Wetmore(at)express-scripts(dot)com>
To: MichaelDBA <MichaelDBA(at)sqlexec(dot)com>, Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: pg_cancel_backend and pg_terminate_backend
Date: 2023-04-19 19:53:19
Message-ID: d10305f0ea744c7c9d279ca327d8d9fb@express-scripts.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

You had to be a SU in 8.0, 9.0 allowed you to cancel your own query.

From: MichaelDBA <MichaelDBA(at)sqlexec(dot)com>
Sent: Wednesday, April 19, 2023 2:46 PM
To: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: [EXTERNAL] Re: pg_cancel_backend and pg_terminate_backend

My experience with the older PG versions is that I couldn't stop a query sometimes with pg_cancel_backend, so I had to resort to pg_terminate_backend.

Regards,
Michael Vitale

Wells Oliver wrote on 4/19/2023 3:41 PM:

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.

--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com<mailto:wellsoliver(at)gmail(dot)com>

Regards,
Michael Vitale
Michaeldba(at)sqlexec(dot)com<mailto:michaelvitale(at)sqlexec(dot)com>
703-600-9343

[cid:image001(dot)jpg(at)01D972CE(dot)AD3DD3C0]

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Wells Oliver 2023-04-19 19:54:00 Re: pg_cancel_backend and pg_terminate_backend
Previous Message Wetmore, Matthew (CTR) 2023-04-19 19:51:17 pg_cancel_backend and pg_terminate_backend