From: hubert depesz lubaczewski <depesz@depesz.com>
To: tanghy.fnst@fujitsu.com <tanghy.fnst@fujitsu.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: [BUG] Deadlock detected when update with multiple clients
Date: Tue, 14 Sep 2021 09:00:19 +0200
Message-ID: <20210914070019.GA10022@depesz.com> (raw)
In-Reply-To: <OS0PR01MB611318903C12DB5B08562B95FBDA9@OS0PR01MB6113.jpnprd01.prod.outlook.com>
References: <OS0PR01MB611318903C12DB5B08562B95FBDA9@OS0PR01MB6113.jpnprd01.prod.outlook.com>
On Tue, Sep 14, 2021 at 03:03:40AM +0000, tanghy.fnst@fujitsu.com wrote:
> I met a deadlock when I update amounts of text-type data with multiple clients.
> And there's no deadlock if I set autovacuum to off. Error messages about the
> deadlock are as follows.
Autovacuum is red herring.
Your queries deadlock because they update all the rows in random order,
so sometimes it goes into deadlock condition.
This is known, is not a bug.
When you're doing multiple updates that might update the same rows (and
yours definitely do), it is important to update them in the same order.
Or lock before.
It's hard to provide solid advise in here, since your test case is
clearly bogus - there is no reason to run more than 1 update of whole
table, with the same update clause, at once.
depesz
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: depesz@depesz.com, tanghy.fnst@fujitsu.com, pgsql-bugs@lists.postgresql.org
Subject: Re: [BUG] Deadlock detected when update with multiple clients
In-Reply-To: <20210914070019.GA10022@depesz.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