From: Mark Scheffer <pg2401k@pinkwin.com>
To: pgsql-bugs@lists.postgresql.org
Cc: pg2401k@pinkwin.com
Subject: Re: BUG #15026: Deadlock using GIST index
Date: Sat, 3 Feb 2018 11:02:24 +0100
Message-ID: <d39ad742dc96e28a498c86fa84a925be.squirrel@mail.pinkwin.com> (raw)
In-Reply-To: <40198189.6847478.1516865520664.JavaMail.app@lor1-app12219.prod.linkedin.com>
References: <40198189.6847478.1516865520664.JavaMail.app@lor1-app12219.prod.linkedin.com>
Hi,
Digging deeper into source code of backend/executor/execIndexing.c, I
found following:
* Exclusion Constraints
* ---------------------
...
*
* There is a chance of deadlock, if two backends insert a tuple at the
* same time, and then perform the scan to check for conflicts. They will
* find each other's tuple, and both try to wait for each other. The
* deadlock detector will detect that, and abort one of the transactions.
* That's fairly harmless, as one of them was bound to abort with a
* "duplicate key error" anyway, although you get a different error
* message.
I guess that my example has this deadlock...
I'm not so happy with "That's fairly harmless". In my case I'm processing
messages from several sessions at a rate of more than 1000 messages per
second per session.
With default deadlock timeout of 1 second, at least two sessions may block
and this may have impact on other sessions which may cascade into a lot of
sessions being in a dead-lock. I had a situation where throughput dropped
to 6 messages per second....
Very simple example of this problem:
1. lookup a record for entity E using exclusion constraint
2. if it does not exist: insert the record
3. If this insert fails, back to 1.
If n sessions try to execute this in parallel, the wait time will be n-1
seconds.
Any chance in changing current Postgresql behavior?
Regards,
Mark
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: pg2401k@pinkwin.com
Subject: Re: BUG #15026: Deadlock using GIST index
In-Reply-To: <d39ad742dc96e28a498c86fa84a925be.squirrel@mail.pinkwin.com>
References: <40198189.6847478.1516865520664.JavaMail.app@lor1-app12219.prod.linkedin.com> <d39ad742dc96e28a498c86fa84a925be.squirrel@mail.pinkwin.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