Getting Killed by Dbx

So last night I ended up having to restart my database. As it turns out, [http://people.planetpostgresql.org/xzilla/index.php?/archives/287-killing-invincible-processes-with-dbx.html killing those processes with dbx] cause each process to shut down uncleanly, leaving locks open and the database thinking that those transactions were still open. This was causing vacuums to be unable to reclaim any space, which was slowly causing performance degredation, and eventually would have caused things to go kablooy. What does that look like? Heres one view of it (and no, you never want to see something like this on your databases)
pgods=# select * from pg_locks where pid not in (select procpid from pg_stat_activity); locktype | database | relation | transactionid | transaction | pid | mode | granted ---------------+----------+----------+---------------+-------------+-------+---------------------+--------- transactionid | | | 194646687 | 194646687 | 20966 | ExclusiveLock | t transactionid | | | 194648857 | 194648857 | 21923 | ExclusiveLock | t relation | 43516 | 43801 | | 194648469 | 21726 | AccessShareLock | t relation | 43516 | 1910021 | | 194648857 | 21923 | AccessShareLock | t relation | 43516 | 8788464 | | 194646687 | 20966 | ShareLock | t relation | 43516 | 8788464 | | 194646687 | 20966 | AccessExclusiveLock | t transactionid | | | 194648342 | 194646687 | 20966 | ExclusiveLock | t relation | 43516 | 8788499 | | 194648857 | 21923 | AccessExclusiveLock | t transactionid | | | 194648933 | 194648933 | 21975 | ExclusiveLock | t relation | 43516 | 44584 | | 194646687 | 20966 | AccessShareLock | t relation | 43516 | 44584 | | 194648933 | 21975 | AccessShareLock | t relation | 43516 | 8788460 | | 194646687 | 20966 | AccessExclusiveLock | t relation | 43516 | 44584 | | 194648469 | 21726 | AccessShareLock | t transactionid | | | 194648901 | 194648857 | 21923 | ExclusiveLock | t transactionid | | | 194648469 | 194648469 | 21726 | ExclusiveLock | t relation | 43516 | 43801 | | 194648933 | 21975 | AccessShareLock | t relation | 43516 | 8788462 | | 194646687 | 20966 | ShareLock | t relation | 43516 | 44584 | | 194648857 | 21923 | AccessShareLock | t relation | 43516 | 43801 | | 194646687 | 20966 | AccessShareLock | t
Yep, those process id’s were the ones I killed from yesterday. So it looks like calling exit from dbx is not safe, and you really should not do it. I do think that using something similar might work if you can find the right call to make, I’ll be doing some testing on that later, but for now remember, don’t use dbx for killing processes!