Re: Alter table never finishes

From: bricklen <bricklen(at)gmail(dot)com>
To: Leonardo M(dot) Ramé <l(dot)rame(at)griensu(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Alter table never finishes
Date: 2013-07-30 17:34:00
Message-ID: CAGrpgQ_JJW553XzdDB0LJ9FMTg61_dTrxMTO=2AgOtOHbLrZWQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jul 30, 2013 at 10:29 AM, Leonardo M. Ramé <l(dot)rame(at)griensu(dot)com>wrote:

> > > select pg_cancel_backend(pid) from pg_stat_activity where pid <>
> > > pg_backend_pid();
>

As Giuseppe mentioned, if you need to kill not just the queries, but the
connection as well, you could use:

select pg_terminate_backend(pid) from pg_stat_activity where pid <>
pg_backend_pid();

That is much safer than kill -9, which if issued against the parent
postgres process will crash your cluster.

>
> Sorry bricklen, I've killed all idle connections with "kill -9 <PID>",
> then I was able to execute the alter table.
>

No problem.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2013-07-30 17:35:05 Re: Alter table never finishes
Previous Message Leonardo M. Ramé 2013-07-30 17:29:21 Re: Alter table never finishes