Skip site navigation (1) Skip section navigation (2)

Re: BUG #5946: Long exclusive lock taken by vacuum (not full)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Christopher Browne <cbbrowne(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Jan Wieck <JanWieck(at)Yahoo(dot)com>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #5946: Long exclusive lock taken by vacuum (not full)
Date: 2011-03-28 20:01:33
Message-ID: 28594.1301342493@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Christopher Browne <cbbrowne(at)gmail(dot)com> writes:
> - Grab timestamp
> - Grab exclusive lock
> - Process [Some number of pages]
> - Check time.
> - If [# of ms] have passed then check to see if anyone else has a lock
> O/S on the table.
>   - Commit & give up the lock for a bit if they do
>   - Go back and process more pages if they don't

Actually, we could simplify that even further.  Keep the code exactly
as-is, but every small-number-of-pages, check to see if someone is
waiting on a conflicting lock, and if so, fall out of the page checking
loop.  Truncate away however many pages we know at that time are safe,
and end the vacuum normally.

We'd have to rejigger the stuff in the lock manager that tries to boot
autovacuum off the lock forcibly, but with a bit of luck that would get
less crocky not more so.

This wouldn't really have any parameters that require tuning, I think,
and the max delay till the lock is released is not too much more than
the time needed for ftruncate().  The really good thing about it is that
vacuum's work is never wasted.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Christopher BrowneDate: 2011-03-28 20:21:50
Subject: Re: BUG #5946: Long exclusive lock taken by vacuum (not full)
Previous:From: Tom LaneDate: 2011-03-28 19:47:46
Subject: Re: BUG #5950: backend terminating after altering table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group