Обсуждение: ERROR: could not serialize access due to concurrent update

Поиск
Список
Период
Сортировка

ERROR: could not serialize access due to concurrent update

От
ROHIT SACHDEVA
Дата:
 Hi All,
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?  


--
Have a Good day !!!

Regards
Rohit Sachdeva

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

От
ROHIT SACHDEVA
Дата:
Also foreign table scan is there on query.

On Tue, May 16, 2023 at 6:08 PM ROHIT SACHDEVA <sachdeva.rohit648@gmail.com> wrote:
 Hi All,
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?  


--
Have a Good day !!!

Regards
Rohit Sachdeva


--
Have a Good day !!!

Regards
Rohit Sachdeva

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

От
Ron
Дата:
Scan, you say?  Add an index to support the FK lookup.

On 5/16/23 08:09, ROHIT SACHDEVA wrote:
Also foreign table scan is there on query.

On Tue, May 16, 2023 at 6:08 PM ROHIT SACHDEVA <sachdeva.rohit648@gmail.com> wrote:
 Hi All,
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?  


--
Have a Good day !!!

Regards
Rohit Sachdeva


--
Have a Good day !!!

Regards
Rohit Sachdeva

--
Born in Arizona, moved to Babylonia.

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

От
Laurenz Albe
Дата:
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.

We need more infrmation, like what foreign data wrapper you are using.

Yours,
Laurenz Albe



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

От
ROHIT SACHDEVA
Дата:
It's a postgres_fdw i am using.


On Tue, 16 May, 2023, 9:03 pm Laurenz Albe, <laurenz.albe@cybertec.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.

We need more infrmation, like what foreign data wrapper you are using.

Yours,
Laurenz Albe

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

От
Laurenz Albe
Дата:
>
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.

Yours,
Laurenz Albe



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

От
ROHIT SACHDEVA
Дата:
Okay ..

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.




On Tue, 16 May, 2023, 10:05 pm Laurenz Albe, <laurenz.albe@cybertec.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.

Yours,
Laurenz Albe

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

От
Scott Ribe
Дата:
> On May 16, 2023, at 11:24 AM, ROHIT SACHDEVA <sachdeva.rohit648@gmail.com> wrote:
>
> 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.

As suggested previously, repeat the query.

It would be good, of course, to reduce the frequency of the errors by figuring out what is conflicting--are the queries
generallytaking too long compared to their frequency? But repeating a query when a lock conflict blocks it would still
bethe ultimate fallback, and is pretty standard practice. 




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

От
Laurenz Albe
Дата:
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.albe@cybertec.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