Re: Re: VACUUM is hanging

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ashley Clark <aclark(at)ghoti(dot)org>
Cc: Postgres General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re: VACUUM is hanging
Date: 2001-05-05 03:54:07
Message-ID: 4278.989034847@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ashley Clark <aclark(at)ghoti(dot)org> writes:
>> Try not to leave open transactions hanging around in your Apache
>> code. An idle database connection couldn't block VACUUM like that;
>> it'd have to have been in the middle of a BEGIN block, or maybe even
>> an unfinished query.

> That appears to be the culprit. I don't really understand why an
> uncommitted SELECT statement could/should lock the table though. How
> does that differ from just an open transaction where no query has
> happened yet?

If you've just done BEGIN then you aren't holding any locks. But having
done a SELECT, you have a read lock on that table, which will persist
until you commit or abort the transaction. A read lock doesn't normally
prevent other transactions from doing things with the table --- but it
does block "exclusive" locks, which are obtained for actions like DROP
TABLE, ALTER TABLE, and VACUUM. Those guys want to know that there
ain't no one messin' with that table.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Muhammad Rusydi 2001-05-05 04:36:01 Re: how can i get plpgsql in function?
Previous Message David Wall 2001-05-05 03:07:04 Re: VACUUM is hanging