From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: pdearquer@gmail.com
Subject: BUG #15153: Serialize error (40001) on first statement suggestion
Date: Fri, 13 Apr 2018 08:31:02 +0000
Message-ID: <152360826272.31227.2303345140954328588@wrigleys.postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15153
Logged by: Pablo Arquer
Email address: pdearquer@gmail.com
PostgreSQL version: 9.4.15
Operating system: Debian Jessie
Description:
Hi,
First, thanks for all the effort you put in PostgreSQL, it's a fantastic
piece of software.
Please consider this concurrent access example:
conn1=> \set AUTOCOMMIT off
conn1=> START TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
conn1=> UPDATE MyTable SET number = 123 WHERE id = 1;
conn2=> \set AUTOCOMMIT off
conn2=> START TRANSACTION ISOLATION LEVEL REPEATABLE READ;
conn2=> SELECT number FROM MyTable WHERE id = 1 FOR UPDATE;
conn2 blocks waiting for conn1
conn1=> COMMIT;
conn2 issues a "could not serialize access due to concurrent update" (40001)
error
This isn't a bug, but the expected behaviour
(https://www.postgresql.org/docs/9.4/static/transaction-iso.html). However,
as the SELECT FOR UPDATE statement is the first of the transaction and there
is nothing which needs to be read repeatably, it is possible to run it
safely after conn2 commits. That is, the transaction internal start can be
delayed to the beginning of the first statement and this first statement
executed following the rules of the READ UNCOMMITTED level.
This approach would make it more efficient (saving unecessary retries) and I
think it'd be safe for all cases.
Hope it helps,
Pablo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pdearquer@gmail.com
Subject: Re: BUG #15153: Serialize error (40001) on first statement suggestion
In-Reply-To: <152360826272.31227.2303345140954328588@wrigleys.postgresql.org>
References: <152360826272.31227.2303345140954328588@wrigleys.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox