pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: maciek@heroku.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #13002: VACUUM to prevent wraparound blocks TRUNCATE
Date: Wed, 8 Apr 2015 16:21:05 -0300
Message-ID: <20150408192105.GV4369@alvh.no-ip.org> (raw)
In-Reply-To: <20150408184155.26383.16053@wrigleys.postgresql.org>
References: <20150408184155.26383.16053@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

maciek@heroku.com wrote:

> If autovacuum is running a VACUUM to prevent wraparound on a certain table,
> it looks like it blocks TRUNCATE of that table, which would obviate the need
> for the VACUUM in the first place (and could happen much more quickly). This
> seems like a usability wart at best--one has to instead kill the autovacuum
> (e.g., via pg_cancel_backend) and then TRUNCATE.

If you had truncated the table before the issue became an emergency,
vacuum would have gave way to truncate.  But when autovacuum sees that
the problem is too serious to ignore, it doesn't give way to anything;
if it did, it would fall prey of the same problem it's trying to avoid.

> This is especially inconvenient when the user trying to truncate does
> not have permission to kill (or even see!) the wraparound VACUUM.
> Would it be possible to have autovacuum yield to a TRUNCATE in this
> situation?

Sounds like we would have to special-case truncate in the deadlock
checker or something like that.  Doesn't seem particularly palatable.

The way this works is that deadlock checker returns "you're blocked but
the culprit is autovacuum" when not in emergency mode; then the other
process sends a signal to autovac which commits suicide.  To fix this
case we would have to add another special code "you're blocked but the
culprit is an emergency vacuum", then the other process sees itself as
truncate then sends signal anyway.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (9+ messages)  latest in thread

Message-ID: <20150408192105.GV4369@alvh.no-ip.org>
Permalink:  ../20150408192105.GV4369@alvh.no-ip.org/
Also on:    postgresql.org/message-id/20150408192105.GV4369@alvh.no-ip.org

 · 

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: alvherre@2ndquadrant.com, maciek@heroku.com
  Subject: Re: BUG #13002: VACUUM to prevent wraparound blocks TRUNCATE
  In-Reply-To: <20150408192105.GV4369@alvh.no-ip.org>
  References: <20150408184155.26383.16053@wrigleys.postgresql.org> <20150408192105.GV4369@alvh.no-ip.org>

* 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