From: | Jan Wieck <JanWieck(at)Yahoo(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Kevin Grittner <kgrittn(at)ymail(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: (auto)vacuum truncate exclusive lock |
Date: | 2013-04-18 15:44:02 |
Message-ID: | 517014C2.80004@Yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 4/12/2013 1:57 PM, Tom Lane wrote:
> Kevin Grittner <kgrittn(at)ymail(dot)com> writes:
>> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I think that the minimum appropriate fix here is to revert the hunk
>>> I quoted, ie take out the suppression of stats reporting and analysis.
>
>> I'm not sure I understand -- are you proposing that is all we do
>> for both the VACUUM command and autovacuum?
>
> No, I said that was the minimum fix.
>
> Looking again at the patch, I note this comment:
>
> /*
> + * We failed to establish the lock in the specified number of
> + * retries. This means we give up truncating. Suppress the
> + * ANALYZE step. Doing an ANALYZE at this point will reset the
> + * dead_tuple_count in the stats collector, so we will not get
> + * called by the autovacuum launcher again to do the truncate.
> + */
>
> and I suppose the rationale for suppressing the stats report was this
> same idea of lying to the stats collector in order to encourage a new
> vacuum attempt to happen right away. Now I'm not sure that that's a
> good idea at all --- what's the reasoning for thinking the table will be
> any less hot in thirty seconds? But if it is reasonable, we need a
> redesign of the reporting messages, not just a hack to not tell the
> stats collector what we did.
Yes, that was the rationale behind it combined with "don't change
function call sequences and more" all over the place.
The proper solution would eventually be to add a block number to the
stats held by the stats collector, which preserves the information about
the last filled block of the table. The decouple the truncate from
vacuum/autovacuum. vacuum/autovacuum will set that block number when
they detect the trailing free space. The analyze step can happen just as
usual and reset stats, which doesn't reset that block number. The
autovacuum launcher goes through its normal logic for launching autovac
or autoanalyze. If it doesn't find any of those to do but the
last-used-block is set, it launches the separate lazy truncate step.
This explicitly moves the truncate, which inherently requires the
exclusive lock and therefore is undesirable even in a manual vacuum,
into the background.
Jan
--
Anyone who trades liberty for security deserves neither
liberty nor security. -- Benjamin Franklin
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2013-04-18 15:44:45 | Re: (auto)vacuum truncate exclusive lock |
Previous Message | Alvaro Herrera | 2013-04-18 15:35:57 | Re: event trigger API documentation? |