summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2025-11-28 09:04:04 +0900
committerMichael Paquier <michael@paquier.xyz>2025-11-28 09:04:04 +0900
commit9ccc049dfe655ca9927f7c62559ec32f4d1f94dd (patch)
tree59c63e338aab37d15388913554926bb4237bd14d /doc/src
parentd167c19295da46be1998dd474841f94170e32597 (diff)
pg_buffercache: Add pg_buffercache_mark_dirty{,_relation,_all}()
This commit introduces three new functions for marking shared buffers as dirty by using the functions introduced in 9660906dbd69: * pg_buffercache_mark_dirty() for one shared buffer. - pg_buffercache_mark_dirt_relation() for all the shared buffers in a relation. * pg_buffercache_mark_dirty_all() for all the shared buffers in pool. The "_all" and "_relation" flavors are designed to address the inefficiency of repeatedly calling pg_buffercache_mark_dirty() for each individual buffer, which can be time-consuming when dealing with with large shared buffers pool. These functions are intended as developer tools and are available only to superusers. There is no need to bump the version of pg_buffercache, 4b203d499c61 having done this job in this release cycle. Author: Nazir Bilal Yavuz <byavuz81@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Aidar Imamov <a.imamov@postgrespro.ru> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Joseph Koshakow <koshy44@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Yuhang Qiu <iamqyh@gmail.com> Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com> Discussion: https://postgr.es/m/CAN55FZ0h_YoSqqutxV6DES1RW8ig6wcA8CR9rJk358YRMxZFmw@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/pgbuffercache.sgml93
1 files changed, 91 insertions, 2 deletions
diff --git a/doc/src/sgml/pgbuffercache.sgml b/doc/src/sgml/pgbuffercache.sgml
index a011c749c8a..2e1b9bbecf4 100644
--- a/doc/src/sgml/pgbuffercache.sgml
+++ b/doc/src/sgml/pgbuffercache.sgml
@@ -43,6 +43,18 @@
<primary>pg_buffercache_evict_all</primary>
</indexterm>
+ <indexterm>
+ <primary>pg_buffercache_mark_dirty</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>pg_buffercache_mark_dirty_relation</primary>
+ </indexterm>
+
+ <indexterm>
+ <primary>pg_buffercache_mark_dirty_all</primary>
+ </indexterm>
+
<para>
This module provides the <function>pg_buffercache_pages()</function>
function (wrapped in the <structname>pg_buffercache</structname> view), the
@@ -52,8 +64,11 @@
<function>pg_buffercache_summary()</function> function, the
<function>pg_buffercache_usage_counts()</function> function, the
<function>pg_buffercache_evict()</function> function, the
- <function>pg_buffercache_evict_relation()</function> function and the
- <function>pg_buffercache_evict_all()</function> function.
+ <function>pg_buffercache_evict_relation()</function> function, the
+ <function>pg_buffercache_evict_all()</function> function, the
+ <function>pg_buffercache_mark_dirty()</function> function, the
+ <function>pg_buffercache_mark_dirty_relation()</function> function and the
+ <function>pg_buffercache_mark_dirty_all()</function> function.
</para>
<para>
@@ -112,6 +127,25 @@
function is restricted to superusers only.
</para>
+ <para>
+ The <function>pg_buffercache_mark_dirty()</function> function allows a block
+ to be marked as dirty in the buffer pool given a buffer identifier. Use of
+ this function is restricted to superusers only.
+ </para>
+
+<para>
+ The <function>pg_buffercache_mark_dirty_relation()</function> function
+ allows all unpinned shared buffers in the relation to be marked as dirty in
+ the buffer pool given a relation identifier. Use of this function is
+ restricted to superusers only.
+</para>
+
+ <para>
+ The <function>pg_buffercache_mark_dirty_all()</function> function allows all
+ unpinned shared buffers to be marked as dirty in the buffer pool. Use of
+ this function is restricted to superusers only.
+ </para>
+
<sect2 id="pgbuffercache-pg-buffercache">
<title>The <structname>pg_buffercache</structname> View</title>
@@ -584,6 +618,61 @@
</para>
</sect2>
+ <sect2 id="pgbuffercache-pg-buffercache-mark-dirty">
+ <title>The <structname>pg_buffercache_mark_dirty</structname> Function</title>
+ <para>
+ The <function>pg_buffercache_mark_dirty()</function> function takes a
+ buffer identifier, as shown in the <structfield>bufferid</structfield>
+ column of the <structname>pg_buffercache</structname> view. It returns
+ information about whether the buffer was marked as dirty.
+ The <structfield>buffer_dirtied</structfield> column is true on success,
+ and false if the buffer was already dirty if the buffer was not valid or
+ if it could not be marked as dirty because it was pinned.
+ The <structfield>buffer_already_dirty</structfield> column is true if
+ the buffer couldn't be marked as dirty because it was already dirty. The
+ result is immediately out of date upon return, as the buffer might become
+ valid again at any time due to concurrent activity. The function is
+ intended for developer testing only.
+ </para>
+ </sect2>
+
+ <sect2 id="pgbuffercache-pg-buffercache-mark-dirty-relation">
+ <title>The <structname>pg_buffercache_mark_dirty_relation</structname> Function</title>
+ <para>
+ The <function>pg_buffercache_mark_dirty_relation()</function> function is
+ very similar to the
+ <function>pg_buffercache_mark_dirty()</function> function.
+ The difference is that the
+ <function>pg_buffercache_mark_dirty_relation()</function> function takes a
+ relation identifier instead of buffer identifier. It tries to mark all
+ buffers dirty for all forks in that relation.
+ It returns the number of buffers marked as dirty, the number of buffers
+ already dirty and the number of buffers skipped because already pinned or
+ invalid.
+ The result is immediately out of date upon return, as the buffer might
+ become valid again at any time due to concurrent activity. The function is
+ intended for developer testing only.
+ </para>
+ </sect2>
+
+ <sect2 id="pgbuffercache-pg-buffercache-mark-dirty-all">
+ <title>The <structname>pg_buffercache_mark_dirty_all</structname> Function</title>
+ <para>
+ The <function>pg_buffercache_mark_dirty_all()</function> function is
+ very similar to the <function>pg_buffercache_mark_dirty()</function>
+ function.
+ The difference is that the
+ <function>pg_buffercache_mark_dirty_all()</function> tries to mark all
+ buffers dirty in the buffer pool.
+ It returns the number of buffers marked as dirty, the number of buffers
+ already dirty and the number of buffers skipped because already pinned or
+ invalid.
+ The result is immediately out of date upon return, as the buffer might
+ become valid again at any time due to concurrent activity. The function is
+ intended for developer testing only.
+ </para>
+ </sect2>
+
<sect2 id="pgbuffercache-sample-output">
<title>Sample Output</title>