pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: gerry gan <xiang.gan.aalto@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Is consistent (deterministic) ordering possible in our case?
Date: Wed, 02 Jun 2021 22:51:39 -0400
Message-ID: <242820.1622688699@sss.pgh.pa.us> (raw)
In-Reply-To: <CAN0LumcSS-4_E+VJgQFG6oVc7YJf2dW5xD2Owqb88Uw2nm3GMw@mail.gmail.com>
References: <CAN0LumeHGPN8U=VxWKHihLwhQC2fQy6b2k1gAQ0-BPdC+pt7WA@mail.gmail.com>
	<CAM+6J97tK9MF1GMP2EeOWguG0no+ENC+5gWrRSFQ-7cJgh4Mgw@mail.gmail.com>
	<CAN0LumcSS-4_E+VJgQFG6oVc7YJf2dW5xD2Owqb88Uw2nm3GMw@mail.gmail.com>

gerry gan <xiang.gan.aalto@gmail.com> writes:
> Thanks for the comments! I have a naive question related to the use of
> advisory lock. Based on my current reasoning about our scenario, consistent
> ordering of commands in two transactions might not help to solve the
> deadlock situation. If advisory lock is used, it can return false in case
> it cannot get lock on certain row. This, however, might occur in both
> transactions. Then it seems to be hard to continue from application side
> since the operation is, by any means, required by application logic. In
> other words, I guess this might cause 'deadlock' in applications. Do you
> have any suggestions to solve this situation? And I'm sorry if my question
> is naive. Thank you!

A common answer to this sort of problem is to be willing to retry
transactions after deadlock failures.  If the deadlocks are common,
maybe this won't be workable from a performance standpoint.  But if
they're rare, or you can tweak things to make them so, think about it.
Retries can be a lot simpler, more robust, and even more performant
than trying to get to a provably-deadlock-free implementation.

			regards, tom lane





view thread (4+ messages)

Message-ID: <242820.1622688699@sss.pgh.pa.us>
Permalink:  ../242820.1622688699@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/242820.1622688699@sss.pgh.pa.us

 · 

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, xiang.gan.aalto@gmail.com
  Subject: Re: Is consistent (deterministic) ordering possible in our case?
  In-Reply-To: <242820.1622688699@sss.pgh.pa.us>
  References: <CAN0LumeHGPN8U=VxWKHihLwhQC2fQy6b2k1gAQ0-BPdC+pt7WA@mail.gmail.com> <CAM+6J97tK9MF1GMP2EeOWguG0no+ENC+5gWrRSFQ-7cJgh4Mgw@mail.gmail.com> <CAN0LumcSS-4_E+VJgQFG6oVc7YJf2dW5xD2Owqb88Uw2nm3GMw@mail.gmail.com> <242820.1622688699@sss.pgh.pa.us>

* 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