public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: michele curioni <[email protected]>
Cc: [email protected]
Subject: Re: Could not serialize access due to read/write dependencies among transactions
Date: Thu, 23 Feb 2023 17:10:56 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAPDic7m0LvwdUtpLS03QZ_gjQ08vax-DFNRqtdmTb7yb2-467Q@mail.gmail.com>
References: <CAPDic7m0LvwdUtpLS03QZ_gjQ08vax-DFNRqtdmTb7yb2-467Q@mail.gmail.com>

michele curioni <[email protected]> writes:
> 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,

Indeed.  I think you're mistaken to claim that the transactions are
running in READ COMMITTED.

> moreover, the two threads are trying to update different rows.

That part's not so hard to explain: serializable mode's tracking of
which rows received updates is a bit lossy.  It might be complaining
just because the updated rows were on the same page.

			regards, tom lane






view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Could not serialize access due to read/write dependencies among transactions
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox