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