Locks on temp table and PREPARE - Mailing list pgsql-hackers

From Emmanuel Cecchet
Subject Locks on temp table and PREPARE
Date
Msg-id 4A2586B4.8020403@frogthinker.org
Whole thread Raw
Responses Re: Locks on temp table and PREPARE  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

As we discussed during PGCon, we are using temp tables in 2PC 
transactions. The temp tables are dropped before PREPARE (or have an ON 
COMMIT DROP option) and never cross transaction boundaries.
In 8.3.1, a patch was introduced to disallow temp tables in 2PC 
transactions and we tried to provide a fix for it (see the long thread 
with Heikki on this list). I am still working on a cleaner patch to 
allow temp tables to be used in 2PC transactions but I did hit a new 
problem that I don't know how to solve cleanly.

Take PG 8.3.0 and try:
BEGIN;
CREATE TEMP TABLE foo (x int) ON COMMIT DROP;
PREPARE TRANSACTION 't1';
[BEGIN;] <-- doesn't really matter if you start a new transaction or not
CREATE TEMP TABLE foo (x int); <-- blocks until t1 commits

I have been tracking down the problem and it looks like 
PostPrepare_Locks is holding the locks on 'foo' for some reason I don't 
really get.

Any suggestion on what should be done differently for temp tables there?

Thanks,
Emmanuel

-- 
Emmanuel Cecchet
FTO @ Frog Thinker 
Open Source Development & Consulting
--
Web: http://www.frogthinker.org
email: manu@frogthinker.org
Skype: emmanuel_cecchet



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Managing multiple branches in git
Next
From: Robert Haas
Date:
Subject: Re: Managing multiple branches in git