Re: Autovacuum stuck for hours, blocking queries

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
Cc: Rakesh Kumar <rakeshkumar464(at)outlook(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Autovacuum stuck for hours, blocking queries
Date: 2017-02-18 15:02:36
Message-ID: 2f98f90e-a74b-2f55-f6bc-767b1d38bf13@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/17/2017 11:54 PM, Michael Paquier wrote:
> On Sat, Feb 18, 2017 at 1:32 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com> wrote:
>> Yes it can. Truncate has been rollbackable for a while now.
>
> Per the docs:
> https://www.postgresql.org/docs/9.6/static/sql-truncate.html
> "TRUNCATE is transaction-safe with respect to the data in the tables:
> the truncation will be safely rolled back if the surrounding
> transaction does not commit."
> In short yes a transaction doing a truncate can be rollbacked.
>

I think the part that confuses people into thinking it can not be
rollbacked is this:

"TRUNCATE is not MVCC-safe. After truncation, the table will appear
empty to concurrent transactions, if they are using a snapshot taken
before the truncation occurred. See Section 13.5 for more details."

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Egon Frerich 2017-02-18 16:33:02 How tö select a column?
Previous Message Michael Paquier 2017-02-18 07:54:10 Re: Autovacuum stuck for hours, blocking queries