Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs
Hi,
In bufmgr.c we have the debugging functions PrintBufferDescs
and PrintPinnedBufs, which are typically hidden behind the flag
#ifdef NOT_USED. These functions reference the old buf->refcount and
buf->flags fields, and so they no longer compile. I attached a patch to
use BUF_STATE_GET_REFCOUNT instead and removed the reference to buf->flags.
Regards,
Jacob Brazeal
Attachments:
trial.patchapplication/octet-stream; name=trial.patchDownload+11-8
Since this patch takes out a lock to read the BufferDesc state, I also need
to release the lock, which I've added to this patch.
On Fri, Jan 17, 2025 at 2:11 PM Jacob Brazeal <jacob.brazeal@gmail.com>
wrote:
Show quoted text
Hi,
In bufmgr.c we have the debugging functions PrintBufferDescs
and PrintPinnedBufs, which are typically hidden behind the flag
#ifdef NOT_USED. These functions reference the old buf->refcount and
buf->flags fields, and so they no longer compile. I attached a patch to
use BUF_STATE_GET_REFCOUNT instead and removed the reference to buf->flags.Regards,
Jacob Brazeal
Attachments:
v2-buf-helper-compile-err.patchapplication/octet-stream; name=v2-buf-helper-compile-err.patchDownload+15-8
Jacob Brazeal <jacob.brazeal@gmail.com> writes:
In bufmgr.c we have the debugging functions PrintBufferDescs
and PrintPinnedBufs, which are typically hidden behind the flag
#ifdef NOT_USED. These functions reference the old buf->refcount and
buf->flags fields, and so they no longer compile. I attached a patch to
use BUF_STATE_GET_REFCOUNT instead and removed the reference to buf->flags.
Hmm. So those functions have not compiled since 48354581a of
2016-04-10, and nobody's noticed. Moreover, whatever use-case
they do have would be reduced a good deal by taking a buffer
lock (which might not be available, or our own process might
hold it already).
I'd vote for just removing them...
regards, tom lane
On Fri, Jan 17, 2025 at 9:53 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Jacob Brazeal <jacob.brazeal@gmail.com> writes:
In bufmgr.c we have the debugging functions PrintBufferDescs
and PrintPinnedBufs, which are typically hidden behind the flag
#ifdef NOT_USED. These functions reference the old buf->refcount and
buf->flags fields, and so they no longer compile. I attached a patch to
use BUF_STATE_GET_REFCOUNT instead and removed the reference tobuf->flags.
Hmm. So those functions have not compiled since 48354581a of
2016-04-10, and nobody's noticed. Moreover, whatever use-case
they do have would be reduced a good deal by taking a buffer
lock (which might not be available, or our own process might
hold it already).I'd vote for just removing them...
regards, tom lane
Sounds good! v3 attached.
Attachments:
v3-buf-helper-compile-err.patchapplication/octet-stream; name=v3-buf-helper-compile-err.patchDownload+0-61
On Fri, Jan 17, 2025 at 11:14:02PM -0800, Jacob Brazeal wrote:
Sounds good! v3 attached.
Removal sounds good to me. Any objections from anybody?
Andres, perhaps you have some experience using that and would prefer
keep them and make them work?
--
Michael
Hi,
On 2025-01-19 09:37:54 +0900, Michael Paquier wrote:
On Fri, Jan 17, 2025 at 11:14:02PM -0800, Jacob Brazeal wrote:
Sounds good! v3 attached.
Removal sounds good to me. Any objections from anybody?
Andres, perhaps you have some experience using that and would prefer
keep them and make them work?
I think they're pretty useless, tbh. There's too many buffers that just
printing them out is helpful - pg_buffercache is going to be a better
bet. When debugging issues where pg_buffercache isn't an option (e.g. because
it's a hang that doesn't allow running pg_buffercache), using
DebugPrintBufferRefcount() is much more targeted.
Greetings,
Andres Freund
Andres Freund <andres@anarazel.de> writes:
On 2025-01-19 09:37:54 +0900, Michael Paquier wrote:
Removal sounds good to me. Any objections from anybody?
Andres, perhaps you have some experience using that and would prefer
keep them and make them work?
I think they're pretty useless, tbh. There's too many buffers that just
printing them out is helpful - pg_buffercache is going to be a better
bet. When debugging issues where pg_buffercache isn't an option (e.g. because
it's a hang that doesn't allow running pg_buffercache), using
DebugPrintBufferRefcount() is much more targeted.
Sounds like we're in agreement. I'll push Jacob's second patch.
regards, tom lane