Re: Prepare Transaction support for ON COMMIT DROP temporary tables

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, Dimitri Fontaine <dimitri(at)citusdata(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Prepare Transaction support for ON COMMIT DROP temporary tables
Date: 2019-01-19 01:39:43
Message-ID: 20190119013943.GD3306@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 18, 2019 at 10:39:46AM -0500, Robert Haas wrote:
> Huh. Well, in that case, I'm not sure I understand we really need to
> do beyond removing the error checks for the case where all tables are
> on-commit-drop.

I have not looked at the patch in details, but we should really be
careful that if we do that the namespace does not remain behind when
performing such transactions so as it cannot be dropped. On my very
recent lookups of this class of problems you can easily finish by
blocking a backend from shutting down when dropping its temporary
schema, with the client, say psql, already able to disconnect. So as
long as the 2PC transaction is not COMMIT PREPARED the backend-side
wait will not be able to complete, blocking a backend slot in shared
memory. PREPARE TRANSACTION is very close to a simple commit in terms
of its semantics, while COMMIT PREPARED is just here to finish
releasing resources.

> It could be useful to do something about the issue with pg_temp
> creation that Tom linked to in the other thread. But even if you
> didn't do that, it'd be pretty easy to work around this in application
> code -- just issue a dummy CREATE TEMP TABLE .. ON COMMIT DROP
> statement the first time you use a connection, so that the temp schema
> definitely exists. So I'm not sure I'd view that as a blocker for
> this patch, even though it's kind of a sucky limitation.

That's not really user-friendly, still workable. Or you could just
call current_schema() ;)
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-01-19 01:49:14 Re: current_logfiles not following group access and instead follows log_file_mode permissions
Previous Message Michael Paquier 2019-01-19 01:33:12 Re: [HACKERS] REINDEX CONCURRENTLY 2.0