Search Postgresql Archives

Re: In certain cases, can UPDATE transactions fail rather than block waiting for “FOR UPDATE lock”?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2018-Jul-20, Praveen Kumar wrote:


> Regarding UPDATEs on rows that are locked via "SELECT FOR UPDATE" in
> another transaction, I read the above as follows: other transactions that
> attempt UPDATE of these rows will be blocked until the current transaction
> ( which did "SELECT FOR UPDATE" for those rows ) ends, unless the columns
> in these rows being UPDATE'ed are those that don't have a unique index on
> them that can be used in a foreign key.
>
> Is this correct ?

No.  What it means that if you UPDATE the columns-indexed-by-unique-idx
then the FOR UPDATE lock is acquired underneath.  If your UPDATE
modifies some other column, then a FOR NO KEY UPDATE lock is acquired
instead.  In both cases, concurrent transactions would be blocked rather
than erroring out.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux