Re: no-arg cluster and locks ...

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: James Robinson <jlrobins(at)socialserve(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: no-arg cluster and locks ...
Date: 2008-02-25 02:01:08
Message-ID: 20080225020108.GD21686@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

James Robinson wrote:
> How does 8.2 [ or 8.3 ] deal with table locking in the face of no-
> argument 'cluster' command? Does it lock all tables it is going to visit
> 'up front', or does it collect locks slowly as it visits tables? If it
> only locks a new table before it visits it, does it unlock it once it is
> done?

It runs on one transaction per table: the lock on each table is grabbed
just before working on it, and released as soon as it is done. Of
course, for each table there are locks on the indexes and toast table
and index involved, too.

> Finally, is it a candidate for deadlock detection and unrolling just as
> other locking ops are [ I can imagine one wouldn't want to deadlock-kill
> the clustering backend, but the backend it contends with might be fodder
> assuming its a lesser command ].

Hmm, I think it could deadlock if someone is holding a lock on, say, an
index, and then attempts to lock the table. I don't recall the exact
details.

> We just some observed an undetected deadlock-ish issue, and the juciest
> aspect was that a db-wide cluster was running.

Can you provide more details? pg_locks, pg_stat_activity, the deadlock
message?

(Hmm, it would be helpful if the deadlock checker were to save the
pg_locks contents and perhaps pg_stat_activity in a file, whenever a
deadlock is detected.)

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Rich 2008-02-25 03:31:53 Re: no-arg cluster and locks ...
Previous Message Erik Jones 2008-02-25 00:08:01 Re: "RETURNS SETOF" function question