Locks

更新时间: 2026-03-28 19:06:49

PolarDB for PostgreSQL uses two categories of locks: lightweight locks (lwlocks) and regular locks. When heavy lock contention occurs, identify the lock category first, then use the appropriate view to locate the blocking process.

Lock categories

CategoryHow to identifyWhere to investigate
Lightweight lock (lwlock)wait_event = lwlock in polar_stat_activitySee Wait events for a full list of lwlock names
Regular lockwait_event in polar_stat_activitywait_object field (blocking process) or pg_locks view
Both lock categories surface through polar_stat_activity. Check the wait_event column to determine which category applies and to get the specific lock or lwlock name.

Diagnose lwlock contention

When the wait_event column value is lwlock, refer to the Wait events topic for definitions of each lwlock name and guidance on resolving contention.

Diagnose regular lock contention

When lock contention occurs with a regular lock, use one of the following methods to identify the blocking process.

Find the blocking process in polar_stat_activity

The wait_object field in polar_stat_activity contains the process holding the lock. Look up that process in the same view to see the query it is running.

Find the blocking process in pg_locks

pg_locks provides a lower-level view of all active locks. You can join it with polar_stat_activity to see both the waiting process and the blocking process side by side.

What's next

After identifying the blocking process, check its query and decide whether to wait for it to finish or take action to resolve the contention. For lwlock contention details and resolution strategies, see Wait events.

上一篇: Wait events 下一篇: SLRU
阿里云首页 云原生数据库 PolarDB 相关技术圈