Re: Queries getting older values (autocommit enabled)

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Queries getting older values (autocommit enabled)
Дата
Msg-id CAKFQuwZ2_-Rd4v6wrDWBX9SZWfibOzHHJbRn4OhpKn3KBcCOCg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Queries getting older values (autocommit enabled)  (Eudald Valcàrcel Lacasa <eudald.valcarcel@gmail.com>)
Ответы Re: Queries getting older values (autocommit enabled)  (Eudald Valcàrcel Lacasa <eudald.valcarcel@gmail.com>)
Список pgsql-bugs
On Sat, Apr 25, 2020 at 12:07 PM Eudald Valcàrcel Lacasa <eudald.valcarcel@gmail.com> wrote:
Hello again,
I've been looking for this issue and I'd like to know the behavior of FOR UPDATE SKIP LOCKED in the following scenario:
* One query does an UPDATE targeting a row in the table
* Another query run in parallel does a SELECT...FOR UPDATE SKIP LOCKED targeting the same (being updated) row on the table.
From SKIP LOCKED definition: . With SKIP LOCKED, any selected rows that cannot be immediately locked are skipped.

Would it mean that the 2nd query wouldn't check the affected row since it's locked by the first query?

Yes.  What else would it mean?

If that's the behavior, is there any way I could make the SELECT query wait for the UPDATE LOCK? Is it recommended? Are there downsides to this approach?


"To prevent the operation from waiting for other transactions to commit, use either the NOWAIT or SKIP LOCKED option."

Which means that if you don't include the NOWAIT clause you, well, wait.

David J.

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

Предыдущее
От: Eudald Valcàrcel Lacasa
Дата:
Сообщение: Re: Queries getting older values (autocommit enabled)
Следующее
От: Eudald Valcàrcel Lacasa
Дата:
Сообщение: Re: Queries getting older values (autocommit enabled)