Locks on temp table and PREPARE

From: Emmanuel Cecchet <manu(at)frogthinker(dot)org>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Locks on temp table and PREPARE
Date: 2009-06-02 20:08:20
Message-ID: 4A2586B4.8020403@frogthinker.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)frogthinker(dot)org
Skype: emmanuel_cecchet

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-06-02 20:09:42 Re: Managing multiple branches in git
Previous Message Andrew Dunstan 2009-06-02 20:06:06 Re: Managing multiple branches in git