Difference between terminate/cancel?

Started by François Beausoleilover 12 years ago3 messagesgeneral
Jump to latest
#1François Beausoleil
francois@teksol.info

Hi!

What is the difference between both? cancel sends QUIT while terminate sends TERM, but what effect does this have on the backends, shared memory, etc?

I had some processes stuck in IDLE in transaction after a machine died (through pgbouncer), and cancel did not close the connections, while terminate did kill the transactions.

The docs at http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE do name the signals, but I can't find other documentation on the effects of TERM/QUIT (I'm on 9.1, but devel says the same thing).

Are there pointers in the docs on the differences?

Thanks!
François

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload
#2Kevin Grittner
Kevin.Grittner@wicourts.gov
In reply to: François Beausoleil (#1)
Re: Difference between terminate/cancel?

François Beausoleil <francois@teksol.info> wrote:

What is the difference between both?

I had some processes stuck in IDLE in transaction after a machine
died (through pgbouncer), and cancel did not close the
connections, while terminate did kill the transactions.

The docs at
http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE
[...]

According to the docs you cite:

pg_cancel_backend(): Cancel a backend's current query
pg_terminate_backend(): Terminate a backend

A connection which is idle or idle in transaction does not have a
current query to cancel, but it has a backend process which can be
terminated.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3François Beausoleil
francois@teksol.info
In reply to: Kevin Grittner (#2)
Re: Difference between terminate/cancel?

Le 2013-08-13 à 13:25, Kevin Grittner a écrit :

François Beausoleil <francois@teksol.info> wrote:

What is the difference between both?

I had some processes stuck in IDLE in transaction after a machine
died (through pgbouncer), and cancel did not close the
connections, while terminate did kill the transactions.

The docs at
http://www.postgresql.org/docs/9.1/static/functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE
[...]

According to the docs you cite:

pg_cancel_backend(): Cancel a backend's current query
pg_terminate_backend(): Terminate a backend

A connection which is idle or idle in transaction does not have a
current query to cancel, but it has a backend process which can be
terminated.

Oh, interesting! Now I understand better. Extracted like that, it's obvious what the difference is.

Thanks!
François

Attachments:

smime.p7sapplication/pkcs7-signature; name=smime.p7sDownload