Could not serialize access due to read/write dependencies among transactions - Mailing list pgsql-sql

From michele curioni
Subject Could not serialize access due to read/write dependencies among transactions
Date
Msg-id CAPDic7m0LvwdUtpLS03QZ_gjQ08vax-DFNRqtdmTb7yb2-467Q@mail.gmail.com
Whole thread Raw
Responses Re: Could not serialize access due to read/write dependencies among transactions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Hi,
we have a Spring Boot application that tries to update two separate rows in a table in 2 separate threads, and it uses the default Transaction Isolation level of READ_COMMITTED.
One of the two threads always succeeds, the other always fails with:
org.postgresql.util.PSQLException: ERROR: could not serialize access due to read/write dependencies among transactions [java] ERROR>  Detail: Reason code: Canceled on identification as a pivot, during write. [java] ERROR>  Hint: The transaction might succeed if retried.

I thought that error could only happen for SERIALIZABLE transactions, and moreover, the two threads are trying to update different rows.

The sql update has a where clause on the primary key:
update table set status='a' where column_a = {value1} and column_b={value2}

The table's primary key is a composition of column_a and column_b

 thread1 and thread2 use different values for value1 and value2

Does anyone have any idea how the problem could happen?

Thanks,
Michele 

pgsql-sql by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Re: How to ensure a log-entry is created based on state of data in other tables
Next
From: Tom Lane
Date:
Subject: Re: Could not serialize access due to read/write dependencies among transactions