Correct usage of FOR UPDATE?

Поиск
Список
Период
Сортировка
От Joe Carr
Тема Correct usage of FOR UPDATE?
Дата
Msg-id AANLkTin1qX+ZSOGsvdY7RH0dkTEkxth-XaAy2DSA8HTd@mail.gmail.com
обсуждение исходный текст
Ответы Re: Correct usage of FOR UPDATE?
Список pgsql-sql
Hello,
I have a simple table-based queue system, and I'd looking for some advice on improving my dequeue function. it boils down to:

SELECT id
FROM queue
WHERE <whereclause>
FOR UPDATE NOWAIT;

which works well, in that no item gets dequeued more that once. The issue, however is that when a contention occurs, the error "could not obtain lock on row in relation" is raised. 

Is there a way that I can rewrite this so that when a contention occurs, there is no error? I would like the "winning" process to lock the row, and the "losing" process to select null rather than raise the rowlock error.

thanks beforehand for any help!

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

Предыдущее
От: Edgardo Portal
Дата:
Сообщение: Re: concatenate question
Следующее
От: Tony Capobianco
Дата:
Сообщение: concatenate question