trace_lwlocks
是一个用于输出 PostgreSQL 日志文件中轻量级锁使用情况信息的开发 全局统一配置参数。
trace_lwlocks
添加于 PostgreSQL 7.2。
用法
trace_lwlocks
是一个开发人员 GUC,仅当在编译 PostgreSQL 时在 src/include/pg_config_manual.h 中定义了宏 LOCK_DEBUG
时才可用。
启用 trace_lwlocks
后,关于咨询锁使用情况的信息将以 LOG
级别写入 PostgreSQL 日志输出。请参阅下面的示例。
默认值
trace_lwlocks
的默认值为:off
。
变更历史
- PostgreSQL 7.2
- 添加 (提交 499abb0c)
示例
启用 trace_lwlocks
时的日志输出示例
[2024-01-02 09:29:40 UTC] LOG: 00000: parameter "trace_lwlocks" changed to "on" [2024-01-02 09:29:40 UTC] LOCATION: ProcessConfigFileInternal, guc.c:565 [2024-01-02 09:29:40 UTC] LOG: 00000: 102351: LWLockAcquire(WALInsert 0x7fb345449880): excl 0 shared 0 haswaiters 0 waiters 0 rOK 1 [2024-01-02 09:29:40 UTC] LOCATION: PRINT_LWDEBUG, lwlock.c:303 [2024-01-02 09:29:40 UTC] LOG: 00000: LWLockAcquire(WALInsert 0x7fb345449880): immediately acquired lock [2024-01-02 09:29:40 UTC] LOCATION: LOG_LWDEBUG, lwlock.c:317 [2024-01-02 09:29:40 UTC] LOG: 00000: 102351: LWLockRelease(WALInsert 0x7fb345449880): excl 1 shared 0 haswaiters 0 waiters 0 rOK 1 [2024-01-02 09:29:40 UTC] LOCATION: PRINT_LWDEBUG, lwlock.c:303 [2024-01-02 09:29:40 UTC] LOG: 00000: 102351: LWLockAcquire(WALInsert 0x7fb345449900): excl 0 shared 0 haswaiters 0 waiters 0 rOK 1 [2024-01-02 09:29:40 UTC] LOCATION: PRINT_LWDEBUG, lwlock.c:303 [2024-01-02 09:29:40 UTC] LOG: 00000: LWLockAcquire(WALInsert 0x7fb345449900): immediately acquired lock [2024-01-02 09:29:40 UTC] LOCATION: LOG_LWDEBUG, lwlock.c:317
参考
- PostgreSQL 文档: trace_lwlocks