Skip to content

Monitor PostgreSQL transaction durations

Per https://gitlab.com/gitlab-com/infrastructure/issues/1448#note_27283592 we should monitor the time it takes for transactions to finish (average, p95, max, etc over time):

Transaction length

  • Long running transaction can cause bloat as VACUUM is unable to mark deleted rows as being available space due to open transactions

  • The view pg_stat_activity includes information about all transactions, when they started, and their current status.

  • Replicas must also be checked for long-running transactions when hot_standby_feedback is being used

  • Connections which are 'idle in transaction' may be worth monitoring for explicitly as these can be particularly problematic