Re: Temporary tables prevent autovacuum, leading to XID wraparound
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: "Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>
Cc: 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-07-30T07:59:16Z
Lists: pgsql-hackers
Attachments
- 0001-Make-autovacuum-more-aggressive-to-remove-orphaned-t.patch (text/x-diff) patch 0001
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
Commits
-
Clarify comment about assignment and reset of temp namespace ID in MyProc
- 9fc9933695af 11.0 landed
- 1339fcc89617 12.0 landed
-
Make autovacuum more aggressive to remove orphaned temp tables
- 943576bddcb5 11.0 landed
- 246a6c8f7b23 12.0 landed
-
Don't count background workers against a user's connection limit.
- 13752743bf70 9.6.2 cited