diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2021-01-06 10:15:19 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2021-01-06 10:46:44 +0100 |
commit | 4656e3d66893f286767285cf74dabb3877068e49 (patch) | |
tree | b6ab45e6cff78f644d54c532331b7247c864f7c6 /src/include/pg_config_manual.h | |
parent | 8900b5a9d59a645b3485f5b046c4c7871b2c4026 (diff) | |
download | postgresql-4656e3d66893f286767285cf74dabb3877068e49.tar.gz |
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
Diffstat (limited to 'src/include/pg_config_manual.h')
-rw-r--r-- | src/include/pg_config_manual.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index 3cbdc6d180..d27c8601fa 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -310,6 +310,45 @@ /* #define RANDOMIZE_ALLOCATED_MEMORY */ /* + * For cache invalidation debugging, define CLOBBER_CACHE_ENABLED to enable + * use of the debug_invalidate_system_caches_always GUC to aggressively flush + * syscache/relcache entries whenever it's possible to deliver invalidations. + * See AcceptInvalidationMessages() in src/backend/utils/cache/inval.c for + * details. + * + * USE_ASSERT_CHECKING builds default to enabling this. It's possible to use + * CLOBBER_CACHE_ENABLED without a cassert build and the implied + * CLOBBER_FREED_MEMORY and MEMORY_CONTEXT_CHECKING options but it's unlikely + * to be as effective at identifying problems. + */ +/* #define CLOBBER_CACHE_ENABLED */ + +#if defined(USE_ASSERT_CHECKING) && !defined(CLOBBER_CACHE_ENABLED) +#define CLOBBER_CACHE_ENABLED +#endif + +/* + * Backwards compatibility for the older compile-time-only cache clobber + * macros. + */ +#if !defined(CLOBBER_CACHE_ENABLED) && (defined(CLOBBER_CACHE_ALWAYS) || defined(CLOBBER_CACHE_RECURSIVELY)) +#define CLOBBER_CACHE_ENABLED +#endif + +/* + * Recover memory used for relcache entries when invalidated. See + * RelationBuildDescr() in src/backend/utils/cache/relcache.c. + * + * This is active automatically for clobber cache builds when clobbering is + * active, but can be overridden here by explicitly defining + * RECOVER_RELATION_BUILD_MEMORY. Define to 1 to always free relation cache + * memory even when clobber is off, or to 0 to never free relation cache + * memory even when clobbering is on. + */ +/* #define RECOVER_RELATION_BUILD_MEMORY 0 */ /* Force disable */ +/* #define RECOVER_RELATION_BUILD_MEMORY 1 */ /* Force enable */ + +/* * Define this to force all parse and plan trees to be passed through * copyObject(), to facilitate catching errors and omissions in * copyObject(). |