Lock:transactionid
Session waiting for other session to complete the transaction. (Session is blocked).
The transactionid wait event in PostgreSQL occurs when a backend process is blocked while waiting for a specific transaction to complete.
For example, Updating the same rows of a table from multiple sessions can lead to this situation.
This is one of the more serious wait events that can significantly impact database performance.
This waitevent indicates that:
- One transaction is waiting for another transaction to finish (commit or abort)
- There is direct transaction ID dependency between sessions
- This typically involves row-level locking scenarios where MVCC (Multi-Version Concurrency Control) can't resolve the conflict
Why it is happening (Root Causes)
Following are common scenarios that lead to transactionid waits:
- Lock Contention: When Transaction A holds locks that Transaction B needs
Example: Long-running UPDATE blocking another UPDATE/DELETE on same rows
- Foreign Key Operations: When checking referential integrity during updates/deletes
- Prepared Transactions: Waiting for a prepared transaction (2PC) to commit/rollback
- Serializable Isolation Level: In SERIALIZABLE isolation, waiting for a potentially conflicting transaction to complete
- VACUUM Operations: When VACUUM is blocked by long-running transactions
Performance Implications
- More severe than tuple waits as it involves entire transactions rather than individual rows
- Can lead to transaction chains where multiple sessions wait in sequence
Often indicates:
- Long-running transactions holding locks
- Application logic issues (transactions staying open too long)
- Insufficient vacuuming leading to transaction ID wraparound prevention