{"Entry":{"collection":"guc","key":"log_lock_failures","name":"log_lock_failures","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Reporting and Logging / What to Log","category_zh":"","changed_in":[],"changes":[{"documentation_changed":false,"fields":{},"from":"17","status":"added","to":"18"}],"content_hash":"a49f0f2776aea60a4eaccd77c38e42afc8e7e410501ce2226911a67a84875698","context":"","default_changed_in":[],"default_history":[{"from":"18","to":"19","value":"off"}],"editorial":{"advice":{"olap":"Analytical readers using SELECT ... NOWAIT can use it during contention investigations; leave it off if those commands are absent because it supplies no broader wait telemetry.","oltp":"Enable it for sessions where SELECT ... NOWAIT failure explains latency or retry behavior, and correlate records with application retries and lock holders. Do not expect coverage of unrelated lock errors.","small":"The normal volume is low, but verify log access and retention before enabling. Pair it with log_lock_waits and deadlock diagnostics rather than treating it as a replacement."},"mechanism":["log_lock_failures was introduced in PostgreSQL 18 to emit a detailed message when a supported lock acquisition fails. In PostgreSQL 18 the supported scope is specifically lock failure caused by SELECT ... NOWAIT; it is not a general logger for every NOWAIT-like command or every lock error.","It is a SUPERUSER-context setting. A superuser or a role with the appropriate SET privilege can change it per session, so role/database defaults and connection-pool reset behavior determine which sessions produce records.","It complements log_lock_waits: log_lock_waits reports waits that cross deadlock_timeout, whereas SELECT ... NOWAIT fails immediately and can be reported here. The detailed message can expose relation, lock, and statement context and must follow the normal log access policy."],"pitfalls":["Assuming PostgreSQL 18 logs every lock acquisition failure; currently only SELECT ... NOWAIT is supported.","Using it instead of log_lock_waits even though immediate failure and a wait exceeding deadlock_timeout are different events.","Enabling it in one pooled session and assuming other sessions inherited the value.","Retaining detailed lock and statement context without appropriate log access, redaction, and retention controls."],"references":[{"title":"PostgreSQL 19 Beta 4: log_lock_failures","url":"https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-LOCK-FAILURES"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["log_checkpoints","log_autovacuum_min_duration","log_lock_waits","log_temp_files","log_replication_commands"],"summary":"log_lock_failures is the PostgreSQL setting that controls whether PostgreSQL logs lock failures."},"enumvals":[],"first_version":"18","group":"Reporting and Logging","group_slug":"logging","imported_at":"2026-09-30T00:40:57.361197+08:00","intro_commit":{"authored_at":"2025-06-03T10:02:55+09:00","discussion":["https://postgr.es/m/7a8198b6-d5b8-4910-b41e-8d3efcbb015d@eisentraut.org"],"hash":"73bdcfab35ec0a7eff1a5dd630cbad8e77054547","subject":"Rename log_lock_failure GUC to log_lock_failures for consistency.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=73bdcfab35ec0a7eff1a5dd630cbad8e77054547"},"key":"log_lock_failures","last_version":"20","max_val":"","min_val":"","name":"log_lock_failures","position":231,"present_in":["18","19","20"],"short_desc":"Controls whether a detailed log message is produced when a lock acquisition fails.","short_desc_zh":"","source_rev":"english-manuals:a8a5f85a32e5b11f6c5ccbfa005bef7b422f8dcdc5b53c0e53e55986bdad2088","unit":"","vartype":"bool"}},"Definition":{"Collection":"guc","Key":"log_lock_failures","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_lock_failures","SourceRevision":"english-manuals:a8a5f85a32e5b11f6c5ccbfa005bef7b422f8dcdc5b53c0e53e55986bdad2088","Facts":{"boot_val":"off","category":"Reporting and Logging / What to Log","context":"superuser","description":"Controls whether a detailed log message is produced when a lock acquisition fails. This is useful for analyzing the causes of lock failures. Currently, only lock failures due to SELECT NOWAIT is supported. The default is off. Only superusers and users with the appropriate SET privilege can change this setting.","doc":{"anchor":"GUC-LOG-LOCK-FAILURES","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"},"documented":true,"enumvals":null,"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"log_lock_failures","short_desc":"Logs lock failures.","source":"pg-settings-source-snapshot","unit":null,"vartype":"bool"},"ManualEvidence":{"doc":{"anchor":"GUC-LOG-LOCK-FAILURES","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"log_lock_failures","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"log_lock_failures","Summary":"","BodyHTML":"\u003cp\u003e控制当获取锁失败时是否生成详细日志消息。这有助于分析锁失败的原因。目前，仅支持由于\u003ccode\u003eSELECT NOWAIT\u003c/code\u003e导致的锁失败。默认值为\u003ccode\u003eoff\u003c/code\u003e。只有超级用户和具有适当\u003ccode\u003eSET\u003c/code\u003e权限的用户才能更改此设置。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"deda089cd0deedd10d776e32b7cfb6377c0450e88eef4912cfdc213d2a2e85d5","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e控制当获取锁失败时是否生成详细日志消息。这有助于分析锁失败的原因。目前，仅支持由于\u003ccode class=\"literal\"\u003eSELECT NOWAIT\u003c/code\u003e导致的锁失败。默认值为\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e。只有超级用户和具有适当\u003ccode class=\"literal\"\u003eSET\u003c/code\u003e权限的用户才能更改此设置。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
