trace_locks

用于发出有关锁使用情况信息的开发 GUC

trace_locks 是一个开发 配置参数,用于在 PostgreSQL 日志文件中发出有关咨询(用户)锁使用情况的信息。

trace_locks 是在 PostgreSQL 7.1 中添加的。

用法

trace_locks 是一个开发人员 GUC,仅当在编译 PostgreSQL 时在 src/include/pg_config_manual.h 中定义了宏 LOCK_DEBUG 时才可用。

启用 trace_locks 后,有关锁使用情况的信息将以级别 LOG 写入 PostgreSQL 日志输出。请参见下面的示例。

默认值

trace_locks 的默认值为:off

更改历史

示例

启用 trace_locks 时日志输出示例

[2024-01-02 09:10:38 UTC] psql postgres postgres LOG:  00000: LockAcquire: lock [5,16388] AccessExclusiveLock
[2024-01-02 09:10:38 UTC] psql postgres postgres LOCATION:  LockAcquireExtended, lock.c:799
[2024-01-02 09:10:38 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT);
[2024-01-02 09:10:38 UTC] psql postgres postgres LOG:  00000: LockAcquire: new: lock(0x7fb387e8cfa8) id(5,16388,0,0,0,1) grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 wait(0) type(AccessExclusiveLock)
[2024-01-02 09:10:38 UTC] psql postgres postgres LOCATION:  LOCK_PRINT, lock.c:337
[2024-01-02 09:10:38 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT);
[2024-01-02 09:10:38 UTC] psql postgres postgres LOG:  00000: LockAcquire: new: proclock(0x7fb38801aec0) lock(0x7fb387e8cfa8) method(1) proc(0x7fb388597af8) hold(0)
[2024-01-02 09:10:38 UTC] psql postgres postgres LOCATION:  PROCLOCK_PRINT, lock.c:349
[2024-01-02 09:10:38 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT);
[2024-01-02 09:10:38 UTC] psql postgres postgres LOG:  00000: LockCheckConflicts: no conflict: proclock(0x7fb38801aec0) lock(0x7fb387e8cfa8) method(1) proc(0x7fb388597af8) hold(0)
[2024-01-02 09:10:38 UTC] psql postgres postgres LOCATION:  PROCLOCK_PRINT, lock.c:349
[2024-01-02 09:10:38 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT);
[2024-01-02 09:10:38 UTC] psql postgres postgres LOG:  00000: GrantLock: lock(0x7fb387e8cfa8) id(5,16388,0,0,0,1) grantMask(100) req(0,0,0,0,0,0,0)=1 grant(0,0,0,0,0,0,0)=1 wait(0) type(AccessExclusiveLock)
[2024-01-02 09:10:38 UTC] psql postgres postgres LOCATION:  LOCK_PRINT, lock.c:337
[2024-01-02 09:10:38 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT);
[2024-01-02 09:10:38 UTC] psql postgres postgres LOG:  00000: LockAcquire: lock [5,16388] AccessExclusiveLock
[2024-01-02 09:10:38 UTC] psql postgres postgres LOCATION:  LockAcquireExtended, lock.c:799
[2024-01-02 09:10:38 UTC] psql postgres postgres STATEMENT:  CREATE TABLE foo (id INT);

分类

开发/测试GUC 配置项锁定

参见

trace_lock_oidmintrace_lwlockstrace_userlockstrace_lock_table

反馈

提交任何关于 "trace_locks" 的评论、建议或更正 在这里