> 28 марта 2019 г., в 18:35, Andrey Borodin <x4...@yandex-team.ru> написал(а):
>>
>> Is this really needed? Isn't the ShareLock on the index sufficient? If so,
>> why?
> There may be concurrent inserts? In GiST they can reorder items on page.
Looks like I've tried to cope with same problem twice:
v3 of the patch used AccessShareLock and many locks with incorrect order.
We could use one of possible solutions: either use ShareLock, or rewrite scan
to correct locking order.
But patches v4-v7 use both.
I think we should use AccessShareLock, as long as we implemented tricky logic
with gist_refind_parent().
>>> + stack->parenttup = gist_refind_parent(rel,
>>> stack->parentblk, stack->blkno, strategy);
>>
>> If the gistplacetopage() stuff is truly necessary, then is it okay to
>> call gist_refind_parent() with the original buffer lock still held
>> like this?
> When we call gist_refind_parent() we hold lock for a child and lock parent.
> We exclude concurrent VACUUM, thus parent cannot become a child for current
> child, because it has to be recycled for such coincidence.
That's merely hard form of paranoia, internal pages are never deleted.
gist_index_parent_check() would work just fine with concurrent VACUUM, INSERTs
and SELECTs.
Best regards, Andrey Borodin.