pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Christopher Browne <cbbrowne@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Jan Wieck <JanWieck@Yahoo.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #5946: Long exclusive lock taken by vacuum (not full)
Date: Mon, 28 Mar 2011 16:01:33 -0400
Message-ID: <28594.1301342493@sss.pgh.pa.us> (raw)
In-Reply-To: <AANLkTik8E4b5QuuAwvTgiZJBpR2KcTxPrVtx=gqvB7NN@mail.gmail.com>
References: <201103250856.p2P8ufGc004544@wwwmaster.postgresql.org>
	<4345.1301066239@sss.pgh.pa.us>
	<AANLkTimiCkmZ5NL=iPUG08TRAd-OJp_M1sR2SCm6c2BL@mail.gmail.com>
	<13556.1301069421@sss.pgh.pa.us>
	<1301080686-sup-7539@alvh.no-ip.org>
	<15329.1301082238@sss.pgh.pa.us>
	<AANLkTimuzhLR64DiNJq8QcMpgKBBmuW6eiErqZCVp+jk@mail.gmail.com>
	<16028.1301086103@sss.pgh.pa.us>
	<AANLkTinoRiEg3Nb=PXLD+c9ehNwh63XLtDJ+q9VbA5==@mail.gmail.com>
	<18898.1301286552@sss.pgh.pa.us>
	<AANLkTinvJgdKC=-ScG-DTELSQu4etYVwr=+NGkvyhKKo@mail.gmail.com>
	<AANLkTik8E4b5QuuAwvTgiZJBpR2KcTxPrVtx=gqvB7NN@mail.gmail.com>

Christopher Browne <cbbrowne@gmail.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



view thread (30+ messages)  latest in thread

Message-ID: <28594.1301342493@sss.pgh.pa.us>
Permalink:  ../28594.1301342493@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28594.1301342493@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, cbbrowne@gmail.com, robertmhaas@gmail.com, JanWieck@Yahoo.com
  Subject: Re: BUG #5946: Long exclusive lock taken by vacuum (not full)
  In-Reply-To: <28594.1301342493@sss.pgh.pa.us>
  References: <201103250856.p2P8ufGc004544@wwwmaster.postgresql.org> <4345.1301066239@sss.pgh.pa.us> <AANLkTimiCkmZ5NL=iPUG08TRAd-OJp_M1sR2SCm6c2BL@mail.gmail.com> <13556.1301069421@sss.pgh.pa.us> <1301080686-sup-7539@alvh.no-ip.org> <15329.1301082238@sss.pgh.pa.us> <AANLkTimuzhLR64DiNJq8QcMpgKBBmuW6eiErqZCVp+jk@mail.gmail.com> <16028.1301086103@sss.pgh.pa.us> <AANLkTinoRiEg3Nb=PXLD+c9ehNwh63XLtDJ+q9VbA5==@mail.gmail.com> <18898.1301286552@sss.pgh.pa.us> <AANLkTinvJgdKC=-ScG-DTELSQu4etYVwr=+NGkvyhKKo@mail.gmail.com> <AANLkTik8E4b5QuuAwvTgiZJBpR2KcTxPrVtx=gqvB7NN@mail.gmail.com> <28594.1301342493@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox