Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieuJ7-0000aO-Ob for pgsql-general@arkaria.postgresql.org; Wed, 11 Dec 2019 05:13:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieuJ5-0004jK-3r for pgsql-general@arkaria.postgresql.org; Wed, 11 Dec 2019 05:13:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieuJ4-0004i5-Oq for pgsql-general@lists.postgresql.org; Wed, 11 Dec 2019 05:13:02 +0000 Received: from mail.saralweb.com ([52.220.40.215] helo=mail.saralweb.org) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieuJ0-0006oU-QE for pgsql-general@postgresql.org; Wed, 11 Dec 2019 05:13:02 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.saralweb.org (Postfix) with ESMTP id BB442C42024B; Wed, 11 Dec 2019 10:42:56 +0530 (IST) X-Virus-Scanned: amavisd-new at saralweb.com Received: from mail.saralweb.org ([127.0.0.1]) by localhost (server23.netgables.com [127.0.0.1]) (amavisd-new, port 12501) with ESMTP id 973xKiTN4k3j; Wed, 11 Dec 2019 10:42:53 +0530 (IST) Received: from localhost.localdomain (unknown [61.247.239.236]) by mail.saralweb.org (Postfix) with ESMTPSA id 3E37FC420BE2; Wed, 11 Dec 2019 10:42:53 +0530 (IST) Subject: Re: Tuple concurrency issue in large objects To: Rene Romero Benavides Cc: Postgres General References: <610855df-f400-4cc3-6d81-85030ff05fa1@saralweb.com> From: Shalini Message-ID: Date: Wed, 11 Dec 2019 10:42:51 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------7FBC97485A5C2D9D9A2F9C8A" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7FBC97485A5C2D9D9A2F9C8A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi Rene, I am using Postgresql 11.2. Major version is 11 and minor version is 2. On 12/10/2019 11:24 AM, Rene Romero Benavides wrote: > Hi Shalini. The usual diagnostic info is your postgresql server > version, major and minor version, such as in 12.1 , the major version > is 12 and the minor version (patch version) is 1. > > > On Fri, Dec 6, 2019 at 9:26 AM Shalini > wrote: > > Hi all, > > I am working on a project which allows multiple users to work on > single > large text document. I am using lo_put to apply only the diff into > the > large object without replacing it with a new lob. While working on > it, I > encountered an error "Tuple concurrently updated". > The error can be reproduced with two psql clients. > > Setup: > > mydb=# create table text_docs(id serial primary key, data oid); > CREATE TABLE > mydb=# insert into text_docs(data) select lo_import('./upload.txt'); > INSERT 0 1 > mydb=# select * from text_docs; >   id |  data > ----+--------- >    1 | 5810130 > (1 rows) > > Now, if we open two psql clients and execute the following commands: > > Client 1: > > mydb=# begin; > BEGIN > mydb=# select lo_put(5810130, 10, '\xaa'); > UPDATE 1 > > Client 2: > > mydb=# select lo_put(5810130, 10, '\xaa'); > > Client 1: > mydb=# commit; > COMMIT > > Client 2: > mydb=# select lo_put(5810130, 10, '\xaa'); > ERROR:  tuple concurrently updated > > Is there a workaround to this concurrency issue without creating a > new > large object? > > Regards > Shalini > > > > > > > -- > El genio es 1% inspiración y 99% transpiración. > Thomas Alva Edison > http://pglearn.blogspot.mx/ > --------------7FBC97485A5C2D9D9A2F9C8A Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi Rene,

I am using Postgresql 11.2. Major version is 11 and minor version is 2.


On 12/10/2019 11:24 AM, Rene Romero Benavides wrote:
Hi Shalini. The usual diagnostic info is your postgresql server version, major and minor version, such as in 12.1 , the major version is 12 and the minor version (patch version) is 1.


On Fri, Dec 6, 2019 at 9:26 AM Shalini <shalini@saralweb.com> wrote:
Hi all,

I am working on a project which allows multiple users to work on single
large text document. I am using lo_put to apply only the diff into the
large object without replacing it with a new lob. While working on it, I
encountered an error "Tuple concurrently updated".
The error can be reproduced with two psql clients.

Setup:

mydb=# create table text_docs(id serial primary key, data oid);
CREATE TABLE
mydb=# insert into text_docs(data) select lo_import('./upload.txt');
INSERT 0 1
mydb=# select * from text_docs;
  id |  data
----+---------
   1 | 5810130
(1 rows)

Now, if we open two psql clients and execute the following commands:

Client 1:

mydb=# begin;
BEGIN
mydb=# select lo_put(5810130, 10, '\xaa');
UPDATE 1

Client 2:

mydb=# select lo_put(5810130, 10, '\xaa');

Client 1:
mydb=# commit;
COMMIT

Client 2:
mydb=# select lo_put(5810130, 10, '\xaa');
ERROR:  tuple concurrently updated

Is there a workaround to this concurrency issue without creating a new
large object?

Regards
Shalini






--
El genio es 1% inspiración y 99% transpiración.
Thomas Alva Edison
http://pglearn.blogspot.mx/


--------------7FBC97485A5C2D9D9A2F9C8A--