pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed From: chenhj <chjischj@163.com>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13723: "duplicate key" error occurs when update delete and insert the same row concurrently
Date: Tue, 27 Oct 2015 01:47:42 +0800 (CST)
Message-ID: <796c1a02.44e.150a5434cf6.Coremail.chjischj@163.com> (raw )
In-Reply-To: <CAMkU=1yaj_42p8zC2Gh7W0gmNsh4mU+sDB4sAPzCvTP_W3h4Zg@mail.gmail.com >
References: <20151025110136.3017.39398@wrigleys.postgresql.org >
<31956.1445787503@sss.pgh.pa.us >
<377d9d8.31c6.150a00b83ea.Coremail.chjischj@163.com >
<CAMkU=1yaj_42p8zC2Gh7W0gmNsh4mU+sDB4sAPzCvTP_W3h4Zg@mail.gmail.com >
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
>Can you reproduce the problem under a higher transaction isolation level?
>
>Cheers,
>
>Jeff
Under higher transaction isolation level(REPEATABLE READ or SERIALIZABLE),
only one transaction's UPDATE could be executed, the second transaction's UPDATE will be blocked util the first transaction committed and then throw "could not serialize access due to concurrent update" error.
[postgres@localhost ~]$ cat test5.sql
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
update tb1 set c=2 where id=1
delete from tb1 where id=1;
insert into tb1 values(1,2);
commit;
[postgres@localhost ~]$ pgbench -n -c 2 -j 2 -t 2 -f test5.sql
client 0 aborted in state 1: ERROR: could not serialize access due to concurrent update
...
---------------------------
2015-10-25 22:55:25.717 EDT 2203 0 LOG: connection received: host=[local]
2015-10-25 22:55:25.718 EDT 2203 0 LOG: connection authorized: user=postgres database=postgres
2015-10-25 22:55:25.722 EDT 2205 0 LOG: connection received: host=[local]
2015-10-25 22:55:25.723 EDT 2206 0 LOG: connection received: host=[local]
2015-10-25 22:55:25.723 EDT 2205 0 LOG: connection authorized: user=postgres database=postgres
2015-10-25 22:55:25.724 EDT 2206 0 LOG: connection authorized: user=postgres database=postgres
2015-10-25 22:55:25.726 EDT 2205 0 LOG: statement: BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
2015-10-25 22:55:25.726 EDT 2206 0 LOG: statement: BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
2015-10-25 22:55:25.726 EDT 2206 0 LOG: statement: update tb1 set c=2 where id=1
2015-10-25 22:55:25.727 EDT 2205 0 LOG: statement: update tb1 set c=2 where id=1
2015-10-25 22:55:25.728 EDT 2206 79520 LOG: statement: delete from tb1 where id=1;
2015-10-25 22:55:25.728 EDT 2206 79520 LOG: statement: insert into tb1 values(1,2);
2015-10-25 22:55:25.728 EDT 2206 79520 LOG: statement: commit;
2015-10-25 22:55:25.729 EDT 2206 0 LOG: statement: BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
2015-10-25 22:55:25.729 EDT 2205 79521 ERROR: could not serialize access due to concurrent update
2015-10-25 22:55:25.729 EDT 2205 79521 STATEMENT: update tb1 set c=2 where id=1
2015-10-25 22:55:25.730 EDT 2206 0 LOG: statement: update tb1 set c=2 where id=1
2015-10-25 22:55:25.730 EDT 2206 79522 LOG: statement: delete from tb1 where id=1;
2015-10-25 22:55:25.730 EDT 2206 79522 LOG: statement: insert into tb1 values(1,2);
2015-10-25 22:55:25.730 EDT 2206 79522 LOG: statement: commit;
Best Regards,
Chen Huajun
view thread (10+ messages) latest in thread
Message-ID: <796c1a02.44e.150a5434cf6.Coremail.chjischj@163.com>
Permalink: ../796c1a02.44e.150a5434cf6.Coremail.chjischj@163.com/
Also on: postgresql.org/message-id/796c1a02.44e.150a5434cf6.Coremail.chjischj@163.com
copy link · copy postgr.es
reply 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: chjischj@163.com, jeff.janes@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: BUG #13723: "duplicate key" error occurs when update delete and insert the same row concurrently
In-Reply-To: <796c1a02.44e.150a5434cf6.Coremail.chjischj@163.com>
References: <20151025110136.3017.39398@wrigleys.postgresql.org> <31956.1445787503@sss.pgh.pa.us> <377d9d8.31c6.150a00b83ea.Coremail.chjischj@163.com> <CAMkU=1yaj_42p8zC2Gh7W0gmNsh4mU+sDB4sAPzCvTP_W3h4Zg@mail.gmail.com> <796c1a02.44e.150a5434cf6.Coremail.chjischj@163.com>
* 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