Re: Temporary tables prevent autovacuum, leading to XID wraparound - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Temporary tables prevent autovacuum, leading to XID wraparound
Date
Msg-id 20180730075916.GB2878@paquier.xyz
Whole thread Raw
In response to RE: Temporary tables prevent autovacuum, leading to XID wraparound  ("Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>)
Responses Re: Temporary tables prevent autovacuum, leading to XID wraparound  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Re: Temporary tables prevent autovacuum, leading to XID wraparound  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Fri, Jul 27, 2018 at 08:27:26AM +0000, Tsunakawa, Takayuki wrote:
> I don't have a strong opinion, but I wonder which of namespace.c or
> autovacuum.c is suitable, because isTempNamespaceInUse is specific to
> autovacuum.

I think that there is also a point in allowing other backends to use it
as well, so I left it in namespace.c.  I have been doing more testing
with this patch today.  In order to catch code paths where this is
triggered I have for example added an infinite loop in do_autovacuum
when finding a temp table which exits once a given on-disk file is
found.  This lets plenty of time to attach autovacuum to a debugger, and
play with other sessions in parallel, so I have checked the
transactional assumption this patch relied on, and tested down to v10 as
that's where removal of orphaned temp relations has been made more
aggressive. This patch can also be applied cleanly there.

The check on MyDatabaseId does not actually matter much as the same
temporary namespace OID would get reused only after an OID wraparound
with a backend using a different database but I left it anyway as that's
more consistent to me to check for database and namespace, and added a
sanity check to make sure that the routine gets called only by a process
connected to a database.

I am going to be out of town for a couple of days, and the next minor
release planned is close by, so I am not pushing that today, but I'd
like to do so after the next minor release if there are no objections.
Attached is a patch with a proposal of commit message.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: "Tsunakawa, Takayuki"
Date:
Subject: RE: How can we submit code patches that implement our (pending)patents?
Next
From: Arthur Zakirov
Date:
Subject: Re: adding tab completions