55P03: lock_not_available
PostgreSQLWhat does it mean?
The requested lock could not be acquired immediately. It usually happens when a lock is requested with NOWAIT while someone else holds it, or when lock_timeout expires.
Why does it happen?
The row/table being locked while using SELECT ... FOR UPDATE NOWAIT or LOCK TABLE ... NOWAIT, or lock_timeout expiring. Most of the time a long transaction is holding the lock.
How to fix it
Find the blocking session: join pg_locks and pg_stat_activity (waiting/blocking relationship). Finish the long transaction or, if necessary, terminate it with pg_terminate_backend(pid). Instead of NOWAIT, wait with a reasonable lock_timeout and add retry logic. Shorten transactions to reduce lock hold time.