От:
Devendra Yadav <devendra.857@gmail.com>
Дата:
Hello,
Hope everything is well with you.
We are running on PostgreSQL v 12.1 , Redhat 7.8.
We are running a query - ALTER TABLE mytable ADD COLUMN deposited DOUBLE PRECISION;
This query is blocked by pid 0. It's not a postgres PID and won't allow to terminate from postgres.
What would be the way forward to troubleshoot this?
Thanks and Regards,
Devendra Yadav
Re: ALTER TABLE blocked
От:
Laurenz Albe <laurenz.albe@cybertec.at>
Дата:
On Tue, 2021-03-30 at 12:36 +0530, Devendra Yadav wrote: > Hope everything is well with you. Thanks, yes. I hope you are fine too. > We are running on PostgreSQL v 12.1 , Redhat 7.8. > We are running a query - ALTER TABLE mytable ADD COLUMN deposited DOUBLE PRECISION; > > This query is blocked by pid 0. It's not a postgres PID and won't allow to terminate from postgres. > What would be the way forward to troubleshoot this? That is probably a stale prepared transaction. Look into "pg_prepared_xacts" for any prepared transactions and use ROLLBACK PREPARED 'name'; to remove stale entries. When using prepared transactions, you must use a transaction manager that does these things for you. Also, you should monitor prepared transactions. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com
Re: ALTER TABLE blocked
От:
Devendra Yadav <devendra.857@gmail.com>
Дата:
Thanks a ton Laurenz.
It worked
Regards,
Devendra Yadav
On Tue, 30 Mar 2021, 16:39 Laurenz Albe, <laurenz.albe@cybertec.at> wrote:
On Tue, 2021-03-30 at 12:36 +0530, Devendra Yadav wrote:
> Hope everything is well with you.
Thanks, yes. I hope you are fine too.
> We are running on PostgreSQL v 12.1 , Redhat 7.8.
> We are running a query - ALTER TABLE mytable ADD COLUMN deposited DOUBLE PRECISION;
>
> This query is blocked by pid 0. It's not a postgres PID and won't allow to terminate from postgres.
> What would be the way forward to troubleshoot this?
That is probably a stale prepared transaction.
Look into "pg_prepared_xacts" for any prepared transactions and use
ROLLBACK PREPARED 'name';
to remove stale entries.
When using prepared transactions, you must use a transaction manager
that does these things for you. Also, you should monitor prepared
transactions.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Re:
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Devendra Yadav writes: > We are running on PostgreSQL v 12.1 , Redhat 7.8. > We are running a query - ALTER TABLE mytable ADD COLUMN deposited DOUBLE > PRECISION; > This query is blocked by pid 0. It's not a postgres PID and won't allow to > terminate from postgres. It would be better if you showed the evidence that makes you think this, as it's fairly likely that the true problem is somewhere else than you think. At a guess, however, a pg_locks display that suggests a lock is held by "pid 0" might be trying to represent a lock held by a prepared-but- uncommitted transaction. Try looking into the pg_prepared_xacts view. regards, tom lane