Re: Strange error related to temporary tables

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strange error related to temporary tables
Дата
Msg-id 8375.1157039554@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Strange error related to temporary tables  (Csaba Nagy <nagy@ecircle-ag.com>)
Список pgsql-general
Csaba Nagy <nagy@ecircle-ag.com> writes:
> In any case, the error message is strange in itself, as if I try to
> create the temporary table when it exists, the error I get in manual
> trial is:
> ERROR:  relation "test_temp_table" already exists
>         ^^^^^^^^
> compared to the error from the OP which I cite here for reference:
> ERROR: type "temp_report" already exists
>        ^^^^

This is not too surprising given the way that heap_create_with_catalog
works --- it happens to be easier to insert the pg_type row before
the pg_class row, so if you have two sessions trying to create the same
table at about the same time, that's where the unique index constraint
will kick in.  The initial check for a duplicate pg_class row doesn't
catch the conflict because the guy who's just slightly ahead won't have
committed yet when the second guy looks.

The question is how is this scenario managing to occur, given that the
tables in question are temp tables?  It seems like this must indicate
two backends trying to use the same pg_temp_NNN schema; but that should
surely be impossible --- it's driven off MyBackendId, and if that's not
unique to a live session then we've got *major* problems.

IIRC we've seen prior reports of similar issues, so I believe there is
something there, but without a test case it's gonna be hard to track down.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Thought provoking piece on NetBSD
Следующее
От: Matthew Schumacher
Дата:
Сообщение: Query performance inconsistant.