mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Replace CLOBBER_CACHE_ALWAYS with run-time GUC
Forced cache invalidation (CLOBBER_CACHE_ALWAYS) has been impractical to use for testing in PostgreSQL because it's so slow and because it's toggled on/off only at build time. It is helpful when hunting bugs in any code that uses the sycache/relcache because causes cache invalidations to be injected whenever it would be possible for an invalidation to occur, whether or not one was really pending. Address this by providing run-time control over cache clobber behaviour using the new debug_invalidate_system_caches_always GUC. Support is not compiled in at all unless assertions are enabled or CLOBBER_CACHE_ENABLED is explicitly defined at compile time. It defaults to 0 if compiled in, so it has negligible effect on assert build performance by default. When support is compiled in, test code can now set debug_invalidate_system_caches_always=1 locally to a backend to test specific queries, functions, extensions, etc. Or tests can toggle it globally for a specific test case while retaining normal performance during test setup and teardown. For backwards compatibility with existing test harnesses and scripts, debug_invalidate_system_caches_always defaults to 1 if CLOBBER_CACHE_ALWAYS is defined, and to 3 if CLOBBER_CACHE_RECURSIVE is defined. CLOBBER_CACHE_ENABLED is now visible in pg_config_manual.h, as is the related RECOVER_RELATION_BUILD_MEMORY setting for the relcache. Author: Craig Ringer <craig.ringer@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/flat/CAMsr+YF=+ctXBZj3ywmvKNUjWpxmuTuUKuv-rgbHGX5i5pLstQ@mail.gmail.com
This commit is contained in:
@ -9989,6 +9989,43 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="guc-debug-invalidate-system-caches-always" xreflabel="debug_invalidate_system_caches_always">
|
||||
<term><varname>debug_invalidate_system_caches_always</varname> (<type>integer</type>)
|
||||
<indexterm>
|
||||
<primary><varname>debug_invalidate_system_caches_always</varname> configuration parameter</primary>
|
||||
</indexterm>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
When set to 1, each cache lookup for a system catalog entry is
|
||||
invalidated at the first possible opportunity, irrespective of whether
|
||||
anything that would render it invalid really occurred. Caching of
|
||||
system catalogs is effectively disabled as a result, so the server
|
||||
will run extremely slowly. Higher values run the cache invalidation
|
||||
recursively, which is even slower and useful only useful for testing
|
||||
in very specific scenarios.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This option can be very helpful when trying to trigger
|
||||
hard-to-reproduce bugs involving concurrency and catalog changes but
|
||||
is otherwise rarely needed. See the source code files
|
||||
<filename>inval.c</filename> and
|
||||
<filename>pg_config_manual.h</filename> for details.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This setting is supported but off by default (0) when
|
||||
<symbol>CLOBBER_CACHE_ENABLED</symbol> is defined at compile time
|
||||
(which happens automatically when using the
|
||||
<literal>configure</literal> option
|
||||
<option>--enable-cassert</option>). In production builds, its value
|
||||
will always be <literal>0</literal> and attempts to set it to another
|
||||
value will raise an error.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="guc-ignore-system-indexes" xreflabel="ignore_system_indexes">
|
||||
<term><varname>ignore_system_indexes</varname> (<type>boolean</type>)
|
||||
<indexterm>
|
||||
|
@ -372,7 +372,8 @@ make check EXTRA_REGRESS_OPTS="--temp-config=test_postgresql.conf"
|
||||
|
||||
<para>
|
||||
This can be useful to enable additional logging, adjust resource limits,
|
||||
or enable extra run-time checks.
|
||||
or enable extra run-time checks such as <xref
|
||||
linkend="guc-debug-invalidate-system-caches-always"/>.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
|
Reference in New Issue
Block a user