Re: Queries getting older values (autocommit enabled) - Mailing list pgsql-bugs

From David G. Johnston
Subject Re: Queries getting older values (autocommit enabled)
Date
Msg-id CAKFQuwZmBiugpSwBGkHN_pTYgpFTkxfnMf-xCA8xuVpdj+TT8Q@mail.gmail.com
Whole thread Raw
In response to Re: Queries getting older values (autocommit enabled)  (Eudald Valcàrcel Lacasa <eudald.valcarcel@gmail.com>)
List pgsql-bugs
On Sat, Apr 25, 2020 at 12:44 PM Eudald Valcàrcel Lacasa <eudald.valcarcel@gmail.com> wrote:
Hello David,
Thanks for your answer.
The actual problem is that my SELECT query is being executed meanwhile the UPDATE one, but instead of waiting for the UPDATE to be executed, it doesn't wait and gets the value from the field prior to the update.
I believed it was because of the MVCC, and I was looking for a workaround to force the select to wait for the UPDATE to finish, instead of taking values of a snapshot.


If you can demonstrate a case where session 1 is holding a transaction open on a completed UPDATE statement and session 2 with a SELECT FOR UPDATE is not waiting for session 1 to commit I am pretty sure you will be demonstrated a bug.

"conversely, SELECT FOR UPDATE will wait for a concurrent transaction that has run any of those commands on the same row, and will then lock and return the updated row (or no row, if the row was deleted)."


David J.
 

pgsql-bugs by date:

Previous
From: Eudald Valcàrcel Lacasa
Date:
Subject: Re: Queries getting older values (autocommit enabled)
Next
From: Tom Lane
Date:
Subject: Re: BUG #16390: Regression between 12.2 and 11.6 on a recursive query : very slow and overestimation of rows