Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mzKGN-0003FH-Rq for pgsql-general@arkaria.postgresql.org; Mon, 20 Dec 2021 15:07:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mzKGM-0006Z5-Nx for pgsql-general@arkaria.postgresql.org; Mon, 20 Dec 2021 15:07:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mzKGM-0006Yv-DW for pgsql-general@lists.postgresql.org; Mon, 20 Dec 2021 15:07:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mzKGK-0004eQ-3c for pgsql-general@lists.postgresql.org; Mon, 20 Dec 2021 15:07:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 1BKF7bHX2377044; Mon, 20 Dec 2021 10:07:38 -0500 From: Tom Lane To: =?utf-8?Q?Sylvain_D=C3=A9ve?= cc: "pgsql-general@lists.postgresql.org" Subject: Re: Update concurrency In-reply-to: <-zxRtNEMT5cJjoFNR4LphpHl907G9wjMd-xShnDUyjZg5cgXZQpRdsNHe6OY96_8eyP9s0cyttLKUwv4FyRrirbUGeEoQe22M0lpaFJSGuo=@protonmail.com> References: <-zxRtNEMT5cJjoFNR4LphpHl907G9wjMd-xShnDUyjZg5cgXZQpRdsNHe6OY96_8eyP9s0cyttLKUwv4FyRrirbUGeEoQe22M0lpaFJSGuo=@protonmail.com> Comments: In-reply-to =?utf-8?Q?Sylvain_D=C3=A9ve?= message dated "Mon, 20 Dec 2021 13:45:29 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2377042.1640012857.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 20 Dec 2021 10:07:37 -0500 Message-ID: <2377043.1640012857@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?utf-8?Q?Sylvain_D=3DC3=3DA9ve?=3D writes= : > # JSONB update for a single selected row and column. > # 'column' and 'select_row' are determined with the parameters 'data= ' and 'path'. > command =3D ( > f"""UPDATE MY_TABLE SET """ > f"""{column} =3D jsonb_merge({column}, %s) """ > f"""WHERE {select_row};""" > ) > When called twice in a row, this call leads to the error (at "cur.execut= e"): > 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