Re: Hash Indexes

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Hash Indexes
Date: 2016-06-23 02:13:41
Message-ID: CAA4eK1+2wd9AWOPgGMQLZZqGhH7D3uJ6V68HxKfYq3-AqVr1Zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 22, 2016 at 8:44 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Wed, Jun 22, 2016 at 5:10 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>>>
>>> I think this is basically correct, although I don't find it to be as
>>> clear as I think it could be. It seems very clear that any operation
>>> which potentially changes the order of tuples in the bucket chain,
>>> such as the squeeze phase as currently implemented, also needs to
>>> exclude all concurrent scans. However, I think that it's OK for
>>> vacuum to remove tuples from a given page with only an exclusive lock
>>> on that particular page.
>>
>> How can we guarantee that it doesn't remove a tuple that is required by scan
>> which is started after split-in-progress flag is set?
>
> If the tuple is being removed by VACUUM, it is dead. We can remove
> dead tuples right away, because no MVCC scan will see them. In fact,
> the only snapshot that will see them is SnapshotAny, and there's no
> problem with removing dead tuples while a SnapshotAny scan is in
> progress. It's no different than heap_page_prune() removing tuples
> that a SnapshotAny sequential scan was about to see.
>
> If the tuple is being removed because the bucket was split, it's only
> a problem if the scan predates setting the split-in-progress flag.
> But since your design involves out-waiting all scans currently in
> progress before setting that flag, there can't be any scan in progress
> that hasn't seen it.
>

For above cases, just an exclusive lock will work.

> A scan that has seen the flag won't look at the
> tuple in any case.
>

Why so? Assume that scan started on new bucket where
split-in-progress flag was set, now it will not look at tuples that
are marked as moved-by-split in this bucket, as it will assume to find
all such tuples in old bucket. Now, if allow Vacuum or someone else
to remove tuples from old with just an Exclusive lock, it is quite
possible that scan miss the tuple in old bucket which got removed by
vacuum.

>>> (Plain text email is preferred to HTML on this mailing list.)
>>>
>>
>> If I turn to Plain text [1], then the signature of my e-mail also changes to
>> Plain text which don't want. Is there a way, I can retain signature
>> settings in Rich Text and mail content as Plain Text.
>
> Nope, but I don't see what you are worried about. There's no HTML
> content in your signature anyway except for a link, and most
> mail-reading software will turn that into a hyperlink even without the
> HTML.
>

Okay, I didn't knew that mail-reading software does that. Thanks for
pointing out.

--

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2016-06-23 02:17:00 Re: Hash Indexes
Previous Message Bruce Momjian 2016-06-23 01:09:09 Re: Questionabl description in datatype.sgml