Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs

Started by Jacob Brazealabout 1 year ago7 messageshackers
Jump to latest
#1Jacob Brazeal
jacob.brazeal@gmail.com

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
#2Jacob Brazeal
jacob.brazeal@gmail.com
In reply to: Jacob Brazeal (#1)
Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs

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
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jacob Brazeal (#1)
Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs

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

#4Jacob Brazeal
jacob.brazeal@gmail.com
In reply to: Tom Lane (#3)
Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs

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 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

Sounds good! v3 attached.

Attachments:

v3-buf-helper-compile-err.patchapplication/octet-stream; name=v3-buf-helper-compile-err.patchDownload+0-61
#5Michael Paquier
michael@paquier.xyz
In reply to: Jacob Brazeal (#4)
Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs

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

#6Andres Freund
andres@anarazel.de
In reply to: Michael Paquier (#5)
Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs

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

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andres Freund (#6)
Re: Old BufferDesc refcount in PrintBufferDescs and PrintPinnedBufs

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