public inbox for [email protected]  
help / color / mirror / Atom feed
From: Bruce Momjian <[email protected]>
To: David Zhang <[email protected]>
Cc: Simon Riggs <[email protected]>
Cc: Cary Huang <[email protected]>
Cc: Pgsql Hackers <[email protected]>
Subject: Re: Patch: Global Unique Index
Date: Mon, 28 Nov 2022 16:28:55 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CANbhV-Eo4D2Njpa=YiBr7BxOMDi5B54wenjgoamRKjzj-9gBGQ@mail.gmail.com>
	<Y4D/[email protected]>
	<[email protected]>

On Fri, Nov 25, 2022 at 05:03:06PM -0800, David Zhang wrote:
> Hi Bruce,
> 
> Thank you for helping review the patches in such detail.
> 
> On 2022-11-25 9:48 a.m., Bruce Momjian wrote:
> 
>     Looking at the patch, I am unclear how the the patch prevents concurrent
>     duplicate value insertion during the partitioned index checking.  I am
>     actually not sure how that can be done without locking all indexes or
>     inserting placeholder entries in all indexes.  (Yeah, that sounds bad,
>     unless I am missing something.)
> 
> For the uniqueness check cross all partitions, we tried to follow the
> implementation of uniqueness check on a single partition, and added a loop to
> check uniqueness on other partitions after the index tuple has been inserted to
> current index partition but before this index tuple has been made visible. The
> uniqueness check will wait `XactLockTableWait` if there is a valid transaction
> in process, and performs the uniqueness check again after the in-process
> transaction finished.

I can't see why this wouldn't work, but I also can't think of any cases
where we do this in our code already, so it will need careful
consideration.

We kind of do this for UPDATE and unique key conflicts, but only for a
single index entry. where we peek and sleep on pending changes, but not
across indexes.

> I am not quite sure if this is a proper way to deal with a deadlock in this
> case. It would be so grateful if someone could help provide some cases/methods
> to verify this cross all partitions uniqueness.

I assume you are using our existing deadlock detection code, and just
sleeping in various indexes and expecting deadlock detection to happen.

-- 
  Bruce Momjian  <[email protected]>        https://momjian.us
  EDB                                      https://enterprisedb.com

Embrace your flaws.  They make you human, rather than perfect,
which you will never be.





view thread (33+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Patch: Global Unique Index
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox