Re: Update concurrency - Mailing list pgsql-general

From Tom Lane
Subject Re: Update concurrency
Date
Msg-id 2377043.1640012857@sss.pgh.pa.us
Whole thread Raw
In response to Update concurrency  (Sylvain Déve <sylvain.deve@protonmail.com>)
List pgsql-general
=?utf-8?Q?Sylvain_D=C3=A9ve?= <sylvain.deve@protonmail.com> writes:
>     # JSONB update for a single selected row and column.
>     # 'column' and 'select_row' are determined with the parameters 'data' and 'path'.
>     command = (
>         f"""UPDATE MY_TABLE SET """
>         f"""{column} = jsonb_merge({column}, %s) """
>         f"""WHERE {select_row};"""
>     )

> When called twice in a row, this call leads to the error (at "cur.execute"):
>     psycopg2.errors.InternalError_: tuple concurrently updated

That error should be pretty hard to reach from user code, and certainly
two successive UPDATEs ought not have anything to do with it.  I think
there is something you're not telling us about the context.  Does this
table have any triggers, weird constraints, or the like?  What is the
actual WHERE clause (ie, I wonder if you have simplified away some
relevant query detail)?  What PG version is this exactly?

            regards, tom lane



pgsql-general by date:

Previous
From: Christoph Moench-Tegeder
Date:
Subject: Re: md5 issues Postgres14 on OL7
Next
From: Tom Lane
Date:
Subject: Re: Update concurrency