Re: ERROR: could not serialize access due to concurrent update

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: ROHIT SACHDEVA <sachdeva(dot)rohit648(at)gmail(dot)com>
Cc: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: ERROR: could not serialize access due to concurrent update
Date: 2023-05-17 06:10:08
Message-ID: c7a7b116bd28a89231c889c2c827d62568b50f93.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I'm getting a bit tired of reformatting your replies into the correct order...

On Tue, 2023-05-16 at 22:54 +0530, ROHIT SACHDEVA wrote:
> On Tue, 16 May, 2023, 10:05 pm Laurenz Albe, <laurenz(dot)albe(at)cybertec(dot)at> wrote:
> > On Tue, 2023-05-16 at 18:39 +0530, ROHIT SACHDEVA wrote:
> > > I am getting this error in the application logs, and this error is frequently coming.
> > > Could someone suggest what would be the best solution to overcome these types of errors.
> > > Isolation of the database is read committed. Should I change the isolation?
> > >
> > > Also foreign table scan is there on query.
> > >
> > > It's a postgres_fdw i am using.
> >
> > That is normal if you modify any data via FDW, because one local query can result in several
> > foreign queries, which have to see the same snapshot of the data.
> >
> > Repeat queries that fail that way, and keep your transactions as short as you can.
>
> But due to this error our transaction is aborted and application team are getting these errors in their logs.
>
> How can I figure this out?
> Can there be work around for not getting this error.

You should be able to avoid these serialization conflicts by using SELECT ... FOR NO KEY UPDATE
whenever you read data that you intend to modify later.

Yours,
Laurenz Albe

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Tim Uckun 2023-05-17 10:01:30 Using pgadmin in docker via compose
Previous Message Wolfgang Wilhelm 2023-05-16 19:32:33 Re: Options for more aggressive space reclamation in vacuuming?