Re: Add pg_buffercache_mark_dirty[_all] functions to the pg_buffercache

From: 邱宇航 <iamqyh(at)gmail(dot)com>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add pg_buffercache_mark_dirty[_all] functions to the pg_buffercache
Date: 2025-11-24 08:47:47
Message-ID: BEB38EF0-CC63-4474-9393-4EFAD8C9966F@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 2025年11月24日 15:50,Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> 写道:
>
> Could you please explain that a bit more? AFAIU, conditional locks are
> mainly used to escape from deadlock situations and we can not cause a
> deadlock here. Is it because using conditional locks might make the
> functions faster by skipping the wait situations?

Bgwriter/Checkpointer might always blocks the mark buffer dirty SQL.

sequence Bgwriter/Checkpointer mark-buffer-dirty SQL
1 LockBuffer(1) WaitBuffer(1)
2 UnlockBuffer(1),
and LockBuffer(2)
3 After unlock wakeup,
WaitBuffer(2)
... ... ...

I don't know if this could really happen. Maybe we need some tests. I
just afraid that pg_buffercache_mark_dirty_{relation, all} SQL could be
slow and inefficient.

> Do you mean that we should not return 'buffer_already_dirty'
> information and we should only return 'buffer_dirtied' information in
> the 'pg_buffercache_mark_dirty' function? If you are suggesting that,
> I think returning 'buffer_already_dirty' has a value in it.

Oops, I read the v7 patch. Ignore this.

Best regards,
Yuhang Qiu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mircea Cadariu 2025-11-24 09:03:41 Re: pg_recvlogical: Prevent flushed data from being re-sent after restarting replication
Previous Message Ivan Bykov 2025-11-24 08:20:00 Re: IPC/MultixactCreation on the Standby server