Re: how do i avoid multiple sessions from inserting the

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: how do i avoid multiple sessions from inserting the
Дата
Msg-id 10225.1046184190@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: how do i avoid multiple sessions from inserting the  (Kolus Maximiliano <Kolus.maximiliano@bcr.com.ar>)
Список pgsql-general
Kolus Maximiliano <Kolus.maximiliano@bcr.com.ar> writes:
>     I tried something slightly different:
> * LOCK the table in SHARE ROW EXCLUSIVE mode,

Well, sure, if you don't mind giving up concurrency of writers completely.
How likely is a conflict, anyway?  If it's very probable then you're not
losing much, but if it's not then this isn't a good approach.

> * If i use LOCK TABLE users IN SHARE ROW EXCLUSIVE MODE in two psql session
> it works (one session gets the lock, the other waits). But inside the
> function it seems to be ignored (i had the dup key problem).

Within a function the snapshot doesn't get updated, so you cannot see
results of other transactions that commit after the function starts.
This means you pretty much have to issue the LOCK as a separate
interactive command.

            regards, tom lane

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

Предыдущее
От: Andrew Perrin
Дата:
Сообщение: Re: Can postgresql be run in memory (like a memory resident
Следующее
От: Ericson Smith
Дата:
Сообщение: Re: 7.4?