Re: Why we need to check for local buffers in BufferIsExclusiveLocked and BufferIsDirty?

From: Srinath Reddy <srinath2133(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Why we need to check for local buffers in BufferIsExclusiveLocked and BufferIsDirty?
Date: 2025-01-26 14:24:45
Message-ID: CAFC+b6oxSB400j529775pzNbEdsAQfrZ_KO18=mwJXOPosK7Qw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

as suggested did the changes and attached the patch for the same.

Regards,
Srinath Reddy Sadipiralla,
EDB: http://www.enterprisedb.com

On Sun, Jan 26, 2025 at 3:20 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Srinath Reddy Sadipiralla <srinath(dot)reddy(at)zohocorp(dot)com> writes:
> >> ---- On Thu, 05 Dec 2024 21:11:42 +0530 Andres Freund <mailto:
> andres(at)anarazel(dot)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
>

Attachment Content-Type Size
0001-Handle-local-buffer-cases-properly.patch application/octet-stream 4.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-01-26 14:46:45 Re: Non-text mode for pg_dumpall
Previous Message Andrew Dunstan 2025-01-26 14:12:49 Re: pg_createsubscriber TAP test wrapping makes command options hard to read.