Обсуждение: How to troubleshoot a halted postgres 8.3 ?

Поиск
Список
Период
Сортировка

How to troubleshoot a halted postgres 8.3 ?

От
"stefan"
Дата:
Hi,

I have a postgres 8.3 db in which I execute a transaction with a lot of alter tabel etc, update etc statements in a
singletransaction. 
I also execute several select statements in parallel.
This puts my database in a state which I would describe as halted, i.e. the sql interface does not respond any more,
pg_adminworks and shows me several transactions running. 

How do I proceed to analyze what's happened? Of course, my first thought is some kind of transaction deadlock, but how
doI check for this ? 

In the status section of pg_admin, I can see a total of 6 transactions running, 3 in idle mode, the other 3 doing some
kindof select. The lock section has several hundred lines listed, but they don't tell me what exactly is locked. 

So, please give me some general idea on how to proceed with such a situation.

Thanks,

Stefan

Re: How to troubleshoot a halted postgres 8.3 ?

От
Scott Mead
Дата:
On Tue, Oct 20, 2009 at 8:46 AM, stefan <stefan@intermediate.de> wrote:

Hi,

I have a postgres 8.3 db in which I execute a transaction with a lot of alter tabel etc, update etc statements in a single transaction.
I also execute several select statements in parallel.
This puts my database in a state which I would describe as halted, i.e. the sql interface does not respond any more, pg_admin works and shows me several transactions running.

  Remember, alter table statements require a full table lock.  So if that transaction (including your update statements) doesn't end somehow (commit, rollback) then all other connections looking at that table will wait.


 
How do I proceed to analyze what's happened? Of course, my first thought is some kind of transaction deadlock, but how do I check for this ?

   Look at the pg_stat_activity and pg_locks views.


--Scott

Re: How to troubleshoot a halted postgres 8.3 ?

От
"stefan"
Дата:
Hi Scott,

>   Remember, alter table statements require a full table lock.  So if that
> transaction (including your update statements) doesn't end somehow (commit,
> rollback) then all other connections looking at that table will wait.

>   Look at the pg_stat_activity and pg_locks views.

Thanks, you were right, I added an additional commit which solved the problem. The hint was that the pg_lock view
containeda lock entry which said granted "No". 

This raises though the question of isolation level, afaik postgres default is committed read. The doc says that another
querywould see the data as it was before the start of the transaction, which in my case would have been fine since the
additionalcolumns created by the alter statement were not used in the select which blocked. 
Is this some kind of "simple" implementation of a committed read ?

Thanks,

Stefan

Re: How to troubleshoot a halted postgres 8.3 ?

От
Scott Mead
Дата:

On Wed, Oct 21, 2009 at 3:05 AM, stefan <stefan@intermediate.de> wrote:



Thanks, you were right, I added an additional commit which solved the problem. The hint was that the pg_lock view contained a lock entry which said granted "No".

This raises though the question of isolation level, afaik postgres default is committed read. The doc says that another query would see the data as it was before the start of the transaction, which in my case would have been fine since the additional columns created by the alter statement were not used in the select which blocked.
Is this some kind of "simple" implementation of a committed read ?

   Right, but that's only for statements that don't take a full table lock.   Since your 'ALTER' statement was locking the whole table, those rules don't apply -- i.e. Everyone even looking (selecting) the table would wait, even if they didn't care about the new columns.  ALTER is a full lock,  no matter what.


--Scott