RE: Temporary tables prevent autovacuum, leading to XID wraparound

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: 'Robert Haas' <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Temporary tables prevent autovacuum, leading to XID wraparound
Date: 2018-02-05 03:10:17
Message-ID: 0A3221C70F24FB45833433255569204D1F8AE239@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

From: Robert Haas [mailto:robertmhaas(at)gmail(dot)com]
> Temporary tables contain XIDs, so they need to be vacuumed for XID
> wraparound. Otherwise, queries against those tables by the session
> that created them could yield wrong answers. However, autovacuum
> can't perform that vacuuming; it would have to be done by the session.
> I think we should consider having backends try to remove their
> temporary schema on startup; then, if a temp table in a backend is old
> enough that it's due for vacuum for wraparound, have autovacuum kill
> the connection. The former is necessary to prevent sessions from
> being killed on account of temp tables they "inherited" from a backend
> that didn't exit cleanly.

The attached patch does the former. The small change in autovacuum.c is mainly for autovac launcher and background workers which don't connect to a database. I'll add this to the next CF. I'd like this to be back-patched.

I didn't do the latter, because killing the connection seemed a bit overkill. If we're going to do it, then we should also kill the connection which is preventing vacuum regardless of whether it has temporary tables in its session.

Regards
Takayuki Tsunakawa

Attachment Content-Type Size
reset_temp_schema_on_connect.patch application/octet-stream 2.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2018-02-05 04:20:51 Re: constraint exclusion and nulls in IN (..) clause
Previous Message Yoshimi Ichiyanagi 2018-02-05 00:59:25 Re: [HACKERS][PATCH] Applying PMDK to WAL operations for persistent memory