Never kill -9 postgres client processes on Linux... but why not?

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Never kill -9 postgres client processes on Linux... but why not?
Date: 2018-04-19 04:40:46
Message-ID: CAOC+FBVsc3ehFduq_z=5H6k2G-KyNCKnBzkzY0Q53nVpEasnhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Had an issue tonight where I had a bunch of stalled queries from a client
connection and I just... could... not... kill... them. We disconnected the
client machine, turned it off, picked it up, shook it around, yelled at it,
and still these idle queries remained in pg_stat_activity.

Then I did select pg_cancel_backend(pid) from pg_stat_activity where
client_addr = '..' and they just would... not... go.. away.

So me being the big smart system administrator guy with shell access, I
logged in, and did a kill -9 xxx where xxx was the sme pid from the
pg_stat_activity result and... they finally went away!

Felt good about myself until I realized, well, so did every other
connection, and in fact PG momentarily went into recovery mode.

Everything was fine, but a) why is it a bad idea to kill -9 a client PG
process, but pg_cancel_backend() is OK-- and b) what to do about stalled PG
queries that won't die when you disconnect AND when you pg_cancel_backend()
them?

Thanks!

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

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Mark Kirkwood 2018-04-19 04:53:31 Re: Never kill -9 postgres client processes on Linux... but why not?
Previous Message Khushboo Vashi 2018-04-19 03:44:16 Re: Possible bug on code autocomplete pgadmin V 3.0