{"Entry":{"collection":"guc","key":"debug_discard_caches","name":"debug_discard_caches","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Developer Options","category_zh":"","changed_in":["18"],"changes":[{"documentation_changed":false,"fields":{},"from":"13","status":"added","to":"14"},{"documentation_changed":false,"fields":{"extra_desc":{"from":null,"to":"0 means use normal caching behavior."}},"from":"17","status":"changed","to":"18"}],"content_hash":"293402bcb53795602450870a18a337dca3601634189b872aacafc21a0dc1676d","context":"","default_changed_in":[],"default_history":[{"from":"14","to":"19","value":"0"}],"derived_content_hash":"db6cf754b671be3ca556217bb46a8a93a4c461757865abc398b578e5b4f880b0","documentation_refresh":{"batch":"20261113","original_source_rev":"wiki-repair-20261023:96e077263813ba00698287867e2f8597ce3b67446512f6a7ed733b47ffad71d2","versions":{"14":"14.25","15":"15.20","16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"editorial":{"advice":{"olap":"Long analytical runs can amplify debug_discard_caches's debug overhead and artifacts. Prefer standard EXPLAIN and statistics first, and isolate any developer experiment from normal users.","oltp":"Do not tune production OLTP with debug_discard_caches. Enable it only for a bounded reproduction with an owner, log/disk budget, rollback condition, and evidence-capture plan; restore the default immediately afterward.","small":"Keep debug_discard_caches at its upstream default. A small host has less spare CPU, disk, connection, and log capacity for developer instrumentation."},"mechanism":["debug_discard_caches invalidates system-catalog cache entries at the earliest opportunity; higher values recurse the behavior. Nonzero values make the server extremely slow to expose cache invalidation bugs.","It is supported only in builds compiled with DISCARD_CACHES_ENABLED, automatically associated with --enable-cassert. Production builds keep zero and reject attempts to change it.","The parameter tests correctness under pathological cache churn. It does not flush shared_buffers, the operating-system page cache, or ordinary query result caches. Its superuser context permits an authorized session change without a server restart."],"pitfalls":["Leaving debug_discard_caches enabled after the bounded diagnostic or recovery task.","Running the experiment on the only copy of production data.","Underestimating log, core-file, temporary-file, WAL, CPU, or connection-slot amplification.","Treating a server that merely starts or completes a query as proof that data and behavior are correct."],"references":[{"title":"PostgreSQL 19 Beta 4: debug_discard_caches","url":"https://www.postgresql.org/docs/19/runtime-config-developer.html#GUC-DEBUG-DISCARD-CACHES"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["ignore_system_indexes","shared_buffers","debug_parallel_query","allow_system_table_mods"],"summary":"debug_discard_caches — Aggressively flush system caches for debugging purposes. Observed in PG14–19 Beta 4; its last measured boot default is 0 in PG19 Beta 4, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"14","group":"Developer Options","group_slug":"developer","imported_at":"2026-09-27T17:57:31.041762+08:00","intro_commit":{"authored_at":"2021-07-13T15:01:01-04:00","discussion":["https://postgr.es/m/1374320.1625430433@sss.pgh.pa.us"],"hash":"6201fa3c166fe2383dd44a9dd5082bc748c2937a","subject":"Rename debug_invalidate_system_caches_always to debug_discard_caches.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=6201fa3c166fe2383dd44a9dd5082bc748c2937a"},"key":"debug_discard_caches","last_version":"20","max_val":"","min_val":"","name":"debug_discard_caches","position":85,"present_in":["14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"english-manuals:c6618266a4ec8995b13afa049ced23a4f99414e6e7565d059b06672ff6614c20","receipt_sha256":"44317a965c2418edafa7ed8c299d7bc1705c68857336a62302b5a3e3506eb476","repair":"wiki-repair-20261023"},"short_desc":"When set to 1, each system catalog cache entry is invalidated at the first possible opportunity, whether or not anything that would render it invalid really occurred.","short_desc_zh":"","source_rev":"wiki-repair-20261023:96e077263813ba00698287867e2f8597ce3b67446512f6a7ed733b47ffad71d2","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"debug_discard_caches","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"debug_discard_caches","SourceRevision":"wiki-repair-20261023:96e077263813ba00698287867e2f8597ce3b67446512f6a7ed733b47ffad71d2","Facts":{"boot_val":"0","category":"Developer Options","context":"superuser","description":"When set to 1, each system catalog cache entry is invalidated at the first possible opportunity, whether or not 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 only useful for testing the caching logic itself. The default value of 0 selects normal catalog caching behavior. This parameter can be very helpful when trying to trigger hard-to-reproduce bugs involving concurrent catalog changes, but it is otherwise rarely needed. See the source code files inval.c and pg_config_manual.h for details. This parameter is supported when DISCARD_CACHES_ENABLED was defined at compile time (which happens automatically when using the configure option --enable-cassert). In production builds, its value will always be 0 and attempts to set it to another value will raise an error.","description_zh":"当设置为 1 时，每个系统目录缓存条目都会在最早可能的时刻被置为无效，无论是否真的发生了使其失效的事件。这实际上禁用了系统目录缓存，因此服务器将运行得非常缓慢。较高的值递归地运行缓存失效，这样会更慢，而且仅对测试缓存逻辑本身有用。默认值 0 选择正常的目录缓存行为。 当试图触发涉及并发目录更改的难以复现的错误时，此参数非常有用，但除此之外很少需要使用它。详情请参见源码文件 inval.c 和 pg_config_manual.h。 只有在编译时定义了 DISCARD_CACHES_ENABLED 时，这个参数才受支持；使用 configure 选项 --enable-cassert 时会自动定义该宏。在生产构建中，它的值始终为 0，尝试将其设置为其他值会引发错误。","description_zh_html":"\u003cp\u003e\n        当设置为 \u003ccode class=\"literal\"\u003e1\u003c/code\u003e 时，每个系统目录缓存条目都会在最早可能的时刻被置为无效，无论是否真的发生了使其失效的事件。这实际上禁用了系统目录缓存，因此服务器将运行得非常缓慢。较高的值递归地运行缓存失效，这样会更慢，而且仅对测试缓存逻辑本身有用。默认值 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e 选择正常的目录缓存行为。\n       \u003c/p\u003e\u003cp\u003e\n        当试图触发涉及并发目录更改的难以复现的错误时，此参数非常有用，但除此之外很少需要使用它。详情请参见源码文件 \u003ccode class=\"filename\"\u003einval.c\u003c/code\u003e 和 \u003ccode class=\"filename\"\u003epg_config_manual.h\u003c/code\u003e。\n       \u003c/p\u003e\u003cp\u003e\n        只有在编译时定义了 \u003ccode class=\"symbol\"\u003eDISCARD_CACHES_ENABLED\u003c/code\u003e 时，这个参数才受支持；使用 \u003cspan class=\"application\"\u003econfigure\u003c/span\u003e 选项 \u003ccode class=\"option\"\u003e--enable-cassert\u003c/code\u003e 时会自动定义该宏。在生产构建中，它的值始终为 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e，尝试将其设置为其他值会引发错误。\n       \u003c/p\u003e","doc":{"anchor":"GUC-DEBUG-DISCARD-CACHES","file":"runtime-config-developer.html","lang":"en","sha256":"a3f6a107ed6ba4edaf6df03e52f4a469bd09350d545e4ff419e62844025ec1cf","slug":"18"},"doc_html":"\u003cp\u003e\n        When set to \u003ccode class=\"literal\"\u003e1\u003c/code\u003e, each system catalog cache entry is\n        invalidated at the first possible opportunity, whether or not\n        anything that would render it invalid really occurred.  Caching of\n        system catalogs is effectively disabled as a result, so the server\n        will run extremely slowly.  Higher values run the cache invalidation\n        recursively, which is even slower and only useful for testing\n        the caching logic itself.  The default value of \u003ccode class=\"literal\"\u003e0\u003c/code\u003e\n        selects normal catalog caching behavior.\n       \u003c/p\u003e\u003cp\u003e\n        This parameter can be very helpful when trying to trigger\n        hard-to-reproduce bugs involving concurrent catalog changes, but it\n        is otherwise rarely needed.  See the source code files\n        \u003ccode class=\"filename\"\u003einval.c\u003c/code\u003e and\n        \u003ccode class=\"filename\"\u003epg_config_manual.h\u003c/code\u003e for details.\n       \u003c/p\u003e\u003cp\u003e\n        This parameter is supported when\n        \u003ccode class=\"symbol\"\u003eDISCARD_CACHES_ENABLED\u003c/code\u003e was defined at compile time\n        (which happens automatically when using the\n        \u003cspan class=\"application\"\u003econfigure\u003c/span\u003e option\n        \u003ccode class=\"option\"\u003e--enable-cassert\u003c/code\u003e).  In production builds, its value\n        will always be \u003ccode class=\"literal\"\u003e0\u003c/code\u003e and attempts to set it to another\n        value will raise an error.\n       \u003c/p\u003e","doc_same_as":"","documentation_revision":{"inputs":[{"file":"runtime-config-developer.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"a3f6a107ed6ba4edaf6df03e52f4a469bd09350d545e4ff419e62844025ec1cf","version":"18.7"},{"file":"runtime-config-developer.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"e7e22aa5738a1d376b84af1adca796c5e14746266733f925eb50c3ef86a50655","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"},"documented":true,"enumvals":null,"extra_desc":"0 means use normal caching behavior.","lang":"en","max_val":"0","metadata_version":"18","min_val":"0","name":"debug_discard_caches","short_desc":"Aggressively flush system caches for debugging purposes.","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-developer.html","sha256":"3c08bf624188bbb0733dc7854e61c0c251c2578311ac3dc8fa626ab21b7911d1"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":null,"vartype":"integer","zh_from":"same-version-manual"},"ManualEvidence":{"doc":{"anchor":"GUC-DEBUG-DISCARD-CACHES","file":"runtime-config-developer.html","lang":"en","sha256":"a3f6a107ed6ba4edaf6df03e52f4a469bd09350d545e4ff419e62844025ec1cf","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"debug_discard_caches","SourceDatabase":"center","Version":"18","Locale":"en","Title":"debug_discard_caches","Summary":"When set to 1, each system catalog cache entry is invalidated at the first possible opportunity, whether or not 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 only useful for testing the caching logic itself. The default value of 0 selects normal catalog caching behavior. This parameter can be very helpful when trying to trigger hard-to-reproduce bugs involving concurrent catalog changes, but it is otherwise rarely needed. See the source code files inval.c and pg_config_manual.h for details. This parameter is supported when DISCARD_CACHES_ENABLED was defined at compile time (which happens automatically when using the configure option --enable-cassert). In production builds, its value will always be 0 and attempts to set it to another value will raise an error.","BodyHTML":"\u003cp\u003e\n        When set to \u003ccode\u003e1\u003c/code\u003e, each system catalog cache entry is\n        invalidated at the first possible opportunity, whether or not\n        anything that would render it invalid really occurred.  Caching of\n        system catalogs is effectively disabled as a result, so the server\n        will run extremely slowly.  Higher values run the cache invalidation\n        recursively, which is even slower and only useful for testing\n        the caching logic itself.  The default value of \u003ccode\u003e0\u003c/code\u003e\n        selects normal catalog caching behavior.\n       \u003c/p\u003e\u003cp\u003e\n        This parameter can be very helpful when trying to trigger\n        hard-to-reproduce bugs involving concurrent catalog changes, but it\n        is otherwise rarely needed.  See the source code files\n        \u003ccode\u003einval.c\u003c/code\u003e and\n        \u003ccode\u003epg_config_manual.h\u003c/code\u003e for details.\n       \u003c/p\u003e\u003cp\u003e\n        This parameter is supported when\n        \u003ccode\u003eDISCARD_CACHES_ENABLED\u003c/code\u003e was defined at compile time\n        (which happens automatically when using the\n        \u003cspan\u003econfigure\u003c/span\u003e option\n        \u003ccode\u003e--enable-cassert\u003c/code\u003e).  In production builds, its value\n        will always be \u003ccode\u003e0\u003c/code\u003e and attempts to set it to another\n        value will raise an error.\n       \u003c/p\u003e","SourceRevision":"wiki-repair-20261023:96e077263813ba00698287867e2f8597ce3b67446512f6a7ed733b47ffad71d2","ContentHash":"9a3d741fad1be423bb676b304f8d749363e4ea34875afe63019f71d91152c6ac","Payload":{"description":"When set to 1, each system catalog cache entry is invalidated at the first possible opportunity, whether or not 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 only useful for testing the caching logic itself. The default value of 0 selects normal catalog caching behavior. This parameter can be very helpful when trying to trigger hard-to-reproduce bugs involving concurrent catalog changes, but it is otherwise rarely needed. See the source code files inval.c and pg_config_manual.h for details. This parameter is supported when DISCARD_CACHES_ENABLED was defined at compile time (which happens automatically when using the configure option --enable-cassert). In production builds, its value will always be 0 and attempts to set it to another value will raise an error."}},"RequestedLocale":"en","Fallback":false,"Versions":["14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
