Re: Why we need to check for local buffers in BufferIsExclusiveLocked and BufferIsDirty?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Srinath Reddy <srinath2133@gmail.com>
Cc: "Andres Freund" <andres@anarazel.de>,
"pgsql-hackers" <pgsql-hackers@lists.postgresql.org>
Date: 2025-01-25T21:50:40Z
Lists: 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
Commits
-
Make BufferIsExclusiveLocked and BufferIsDirty work for local buffers.
- f6ff75f79689 18.0 landed