Re: Is consistent (deterministic) ordering possible in our case? - Mailing list pgsql-general

From Tom Lane
Subject Re: Is consistent (deterministic) ordering possible in our case?
Date
Msg-id 242820.1622688699@sss.pgh.pa.us
Whole thread Raw
In response to Re: Is consistent (deterministic) ordering possible in our case?  (gerry gan <xiang.gan.aalto@gmail.com>)
List pgsql-general
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



pgsql-general by date:

Previous
From: gerry gan
Date:
Subject: Re: Is consistent (deterministic) ordering possible in our case?
Next
From: Ram Pratap Maurya
Date:
Subject: RE: BUG #17046: Upgrade postgres 11 to 13 version