aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2024-04-07 09:13:17 +1200
committerThomas Munro <tmunro@postgresql.org>2024-04-08 16:23:40 +1200
commit13453eedd3f692f8dcf8e334396eee84f00fdde2 (patch)
tree728c8d99691e600f04d334e9f56556cd99f003e0 /doc/src
parent0ea51bac3802dca9dcf5cbaaf7a19a1c1ae4781a (diff)
downloadpostgresql-13453eedd3f692f8dcf8e334396eee84f00fdde2.tar.gz
postgresql-13453eedd3f692f8dcf8e334396eee84f00fdde2.zip
Add pg_buffercache_evict() function for testing.
When testing buffer pool logic, it is useful to be able to evict arbitrary blocks. This function can be used in SQL queries over the pg_buffercache view to set up a wide range of buffer pool states. Of course, buffer mappings might change concurrently so you might evict a block other than the one you had in mind, and another session might bring it back in at any time. That's OK for the intended purpose of setting up developer testing scenarios, and more complicated interlocking schemes to give stronger guararantees about that would likely be less flexible for actual testing work anyway. Superuser-only. Author: Palak Chaturvedi <chaturvedipalak1911@gmail.com> Author: Thomas Munro <thomas.munro@gmail.com> (docs, small tweaks) Reviewed-by: Nitin Jadhav <nitinjadhavpostgres@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Cary Huang <cary.huang@highgo.ca> Reviewed-by: Cédric Villemain <cedric.villemain+pgsql@abcsql.com> Reviewed-by: Jim Nasby <jim.nasby@gmail.com> Reviewed-by: Maxim Orlov <orlovmg@gmail.com> Reviewed-by: Thomas Munro <thomas.munro@gmail.com> Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/CALfch19pW48ZwWzUoRSpsaV9hqt0UPyaBPC4bOZ4W+c7FF566A@mail.gmail.com
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/pgbuffercache.sgml39
1 files changed, 33 insertions, 6 deletions
diff --git a/doc/src/sgml/pgbuffercache.sgml b/doc/src/sgml/pgbuffercache.sgml
index afe2d978340..4b90eefc0b0 100644
--- a/doc/src/sgml/pgbuffercache.sgml
+++ b/doc/src/sgml/pgbuffercache.sgml
@@ -11,6 +11,8 @@
<para>
The <filename>pg_buffercache</filename> module provides a means for
examining what's happening in the shared buffer cache in real time.
+ It also offers a low-level way to evict data from it, for testing
+ purposes.
</para>
<indexterm>
@@ -21,11 +23,16 @@
<primary>pg_buffercache_summary</primary>
</indexterm>
+ <indexterm>
+ <primary>pg_buffercache_evict</primary>
+ </indexterm>
+
<para>
This module provides the <function>pg_buffercache_pages()</function>
function (wrapped in the <structname>pg_buffercache</structname> view),
- the <function>pg_buffercache_summary()</function> function, and the
- <function>pg_buffercache_usage_counts()</function> function.
+ the <function>pg_buffercache_summary()</function> function, the
+ <function>pg_buffercache_usage_counts()</function> function and
+ the <function>pg_buffercache_evict()</function> function.
</para>
<para>
@@ -47,9 +54,15 @@
</para>
<para>
- By default, use is restricted to superusers and roles with privileges of the
- <literal>pg_monitor</literal> role. Access may be granted to others
- using <command>GRANT</command>.
+ By default, use of the above functions is restricted to superusers and roles
+ with privileges of the <literal>pg_monitor</literal> role. Access may be
+ granted to others using <command>GRANT</command>.
+ </para>
+
+ <para>
+ The <function>pg_buffercache_evict()</function> function allows a block to
+ be evicted from the buffer pool given a buffer identifier. Use of this
+ function is restricted to superusers only.
</para>
<sect2 id="pgbuffercache-pg-buffercache">
@@ -351,7 +364,21 @@
</para>
</sect2>
- <sect2 id="pgbuffercache-sample-output">
+ <sect2 id="pgbuffercache-pg-buffercache-evict">
+ <title>The <structname>pg_buffercache_evict</structname> Function</title>
+ <para>
+ The <function>pg_buffercache_evict()</function> function takes a buffer
+ identifier, as shown in the <structfield>bufferid</structfield> column of
+ the <structname>pg_buffercache</structname> view. It returns true on success,
+ and false if the buffer wasn't valid, if it couldn't be evicted because it
+ was pinned, or if it became dirty again after an attempt to write it out.
+ 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>
<screen>