Re: Temporary table already exists - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Temporary table already exists
Date
Msg-id 52F3820D.6070104@gmail.com
Whole thread Raw
In response to Re: Temporary table already exists  (mephysto <mephystoonhell@gmail.com>)
List pgsql-general
On 02/06/2014 12:09 AM, mephysto wrote:
> Hi Adrian,
> it is not an artifact. This log comes from a multiplayer game, and this
> is an specific test to replicate the error. Practically, there are two
> users that execute the same operation, so you can see the simultaneous
> selects.
>
> My opinion was every session was isolated from others and temporary
> table was atomic for every session (transaction).

Well sessions and transactions are not the same thing. A  simple
explanation:

A session is a specific connection to a database.

A transaction is a unit of work. It can be explicitly bounded by
BEGIN/COMMIT(ROLLBACK). In Postgres if you do not supply the BEGIN each
statement gets one, so each statement is in a transaction.

So a session can have one transaction or multiple.

>
> But I think that I'm not true.
>
> Are The two selects in the same session in my case? Why?

The issue to me at least, assuming Postgres is working properly, is that
you have two selects in the same transaction. The ON COMMIT DROP should
drop the table at the end of the transaction. Now as Alban wrote it is
possible that the table is being cached somehow. One suggestion I on
that line of thought is to use dynamic commands:

http://www.postgresql.org/docs/9.2/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

It is also possible, as mentioned previously, that the Java code is
misbehaving. That there are threads interfering with each other. I am
not a Java programmer so I can not be of any help there.

>
> Thanks in advance.
>
> Mephysto
>
>
>

--
Adrian Klaver
adrian.klaver@gmail.com


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: client encoding that psql command sets
Next
From: Rémi Cura
Date:
Subject: Re: Ordering Results by a Supplied Order