Re: Temporary tables prevent autovacuum, leading to XID wraparound

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Andres Freund <andres@anarazel.de>, pgsql-hackers@lists.postgresql.org, "Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>, Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>, "tgl@sss.pgh.pa.us" <tgl@sss.pgh.pa.us>, "robertmhaas@gmail.com" <robertmhaas@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2018-08-14T16:53:32Z
Lists: pgsql-hackers

Attachments

On Mon, Aug 13, 2018 at 01:53:18PM -0300, Alvaro Herrera wrote:
> I do share Andres' concerns on the wording the comment.  I would say
> something like
> 
> /*
>  * Reset the temporary namespace flag in MyProc.  We assume this to be
>  * an atomic assignment.
>  *
>  * Because this subtransaction is rolling back, the pg_namespace
>  * row is not visible to anyone else anyway, but that doesn't matter:
>  * it's not a problem if objects contained in this namespace are removed
>  * concurrently.
>  */

> The fact of assignment being atomic and the fact of the pg_namespace row
> being visible are separately important.  You care about it being atomic
> because it means you must not have someone read "16" (0x10) when you
> were partway removing the value "65552" (0x10010), thus causing that
> someone removing namespace 16.  And you care about the visibility of the
> pg_namespace row because of whether you're worried about a third party
> removing the tables from that namespace or not: since the subxact is
> aborting, you are not.

I was thinking about adding "Even if it is not atomic" or such at the
beginning of the paragraph, but at the end your phrasing sounds better
to me.  So I have hacked up the attached, which also reworks the comment
in InitTempTableNamespace in the same spirit.  Thoughts?
--
Michael

Commits

  1. Clarify comment about assignment and reset of temp namespace ID in MyProc

  2. Make autovacuum more aggressive to remove orphaned temp tables

  3. Don't count background workers against a user's connection limit.