From: Stephen Frost <sfrost@snowman.net>
To: Thomas Poty <thomas.poty@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: algo for canceling a deadlocked transaction
Date: Mon, 9 Apr 2018 09:51:21 -0400
Message-ID: <20180409135121.GJ27724@tamriel.snowman.net> (raw)
In-Reply-To: <CAN_ctnis=pqqMbM3boVRu7uPJxRi20fpcGeqUaC0pWTFUZXmzQ@mail.gmail.com>
References: <CAN_ctnis=pqqMbM3boVRu7uPJxRi20fpcGeqUaC0pWTFUZXmzQ@mail.gmail.com>
Greetings,
* Thomas Poty (thomas.poty@gmail.com) wrote:
> My question is : In case of a deadlock between 2 transaction, how to know
> which transaction will be canceled? Is it predictable?
The short answer is "it's whichever one detected the deadlock." The
deadlock timeout fires after a lock has been held that long and if a
deadlock is detected then the process detecting it will be canceled.
I'd strongly recommend reviewing your application and addressing
deadlocks by changing how the application acquires locks to be
consistent and to avoid lock escalation instead of worrying about how to
predict a deadlock- a properly designed and written application
shouldn't be causing deadlocks to happen in the first place.
Thanks!
Stephen
Attachments:
signature.asc (application/pgp-signature, 818B) download
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-general@postgresql.org
Cc: sfrost@snowman.net, thomas.poty@gmail.com
Subject: Re: algo for canceling a deadlocked transaction
In-Reply-To: <20180409135121.GJ27724@tamriel.snowman.net>
References: <CAN_ctnis=pqqMbM3boVRu7uPJxRi20fpcGeqUaC0pWTFUZXmzQ@mail.gmail.com> <20180409135121.GJ27724@tamriel.snowman.net>
* 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