Re: race condition in pg_class

From: Noah Misch <noah(at)leadboat(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Nitin Motiani <nitinmotiani(at)google(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Smolkin Grigory <smallkeen(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Alexander Lakhin <exclusion(at)gmail(dot)com>
Subject: Re: race condition in pg_class
Date: 2024-09-04 19:57:20
Message-ID: 20240904195720.cf.nmisch@google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 04, 2024 at 09:00:32PM +0530, Nitin Motiani wrote:
> How about this alternative then? The tuple length check
> and the elog(ERROR) gets its own function. Something like
> heap_inplace_update_validate or
> heap_inplace_update_validate_tuple_length. So in that case, it would
> look like this :
>
> genam.c:systable_inplace_update_finish
> heapam.c:heap_inplace_update_validate/heap_inplace_update_precheck
> PreInplace_Inval
> START_CRIT_SECTION
> heapam.c:heap_inplace_update
> BUFFER_LOCK_UNLOCK
> AtInplace_Inval
> END_CRIT_SECTION
> UnlockTuple
> AcceptInvalidationMessages
>
> This is starting to get complicated though so I don't have any issues
> with just renaming the heap_inplace_update to
> heap_inplace_update_and_unlock.

Complexity aside, I don't see the _precheck design qualifying as a modularity
improvement.

> Assert(rel->ri_needsLockTagTuple == IsInplaceUpdateRelation(rel->relationDesc)
>
> This can safeguard against users of ResultRelInfo missing this field.

v10 does the rename and adds that assertion. This question remains open:

On Thu, Aug 22, 2024 at 12:32:00AM -0700, Noah Misch wrote:
> On Tue, Aug 20, 2024 at 11:59:45AM +0300, Heikki Linnakangas wrote:
> > How many of those for RELKIND_INDEX vs tables? I'm thinking if we should
> > always require a tuple lock on indexes, if that would make a difference.
>
> Three sites. See attached inplace125 patch. Is it a net improvement? If so,
> I'll squash it into inplace120.

If nobody has an opinion, I'll discard inplace125. I feel it's not a net
improvement, but either way is fine with me.

Attachment Content-Type Size
inplace090-LOCKTAG_TUPLE-eoxact-v10.patch text/plain 1.3 KB
inplace110-successors-v10.patch text/plain 44.5 KB
inplace120-locktag-v10.patch text/plain 47.4 KB
inplace125-no-exception-for-indexes-v10.patch text/plain 10.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2024-09-04 20:10:37 Re: json_query conditional wrapper bug
Previous Message Jonathan S. Katz 2024-09-04 19:20:33 Re: Large expressions in indexes can't be stored (non-TOASTable)