Re: Why we need to check for local buffers in BufferIsExclusiveLocked and BufferIsDirty? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Why we need to check for local buffers in BufferIsExclusiveLocked and BufferIsDirty?
Date
Msg-id 773837.1737841840@sss.pgh.pa.us
Whole thread Raw
In response to Re: Why we need to check for local buffers in BufferIsExclusiveLocked and BufferIsDirty?  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Srinath Reddy Sadipiralla <srinath.reddy@zohocorp.com> writes:
>> ---- On Thu, 05 Dec 2024 21:11:42 +0530 Andres Freund <mailto:andres@anarazel.de> wrote ---
>> The gain by not dealing with local buffers in these functions is fairly small
>> too, so there's not really any reason for a change like yours.

> hmm got it,if thats the case, for local buffers lockbuffer will skip acquiring content lock, so assert will fail in
BufferIsDirty.

I think you are right about that, but

(1) it seems to be general style to check BufferIsPinned before
checking the content lock, and you've made that out-of-order.
This is easily fixed by moving the Assert(BufferIsPinned(buffer))
to earlier in the function.

(2) I don't think we should touch this but not worry about
BufferIsExclusiveLocked: it's unlikely to behave well on local
buffers either, since we don't initialize content locks for them.
We could either Assert that that's not applied to local buffers,
or act as though their lock is always held.  Given Andres' argument
probably the latter is better.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: doc: explain pgstatindex fragmentation
Next
From: Tom Lane
Date:
Subject: Re: Convert sepgsql tests to TAP