Re: pg_stat_database deadlock counter

Lists: pgsql-hackers
From: Magnus Hagander <magnus(at)hagander(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_stat_database deadlock counter
Date: 2012-01-16 20:19:27
Message-ID: CABUevExaBznSvZ-kuUS9SPg8pQnAGhYBzLeR6ULgjc_E7Rv-4Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Attached patch adds a counter for number of deadlocks in a database to
pg_stat_database.

While not enough to diagnose a problem on it's own, this is an easy
way to get an indicator when for when you need to go look in the logs
for details. Overhead should be very small - one counter per database
is not enough to bloat the statsfile,and if you have enough deadlocks
that the sendinf of the messages actually cause a performance
overhead, you have a bigger problem...

Comments?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

Attachment Content-Type Size
pg_stat_database_deadlock.patch text/x-patch 18.0 KB

From: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stat_database deadlock counter
Date: 2012-01-22 18:35:19
Message-ID: CAJKUy5i2_ypJg3UMAyUdzRAa0C4HPQPO9PQ+NGzXwkGKjB4FpA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Jan 16, 2012 at 3:19 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
> Attached patch adds a counter for number of deadlocks in a database to
> pg_stat_database.
>

A little review:

- it applies with a few hunks
- the oid you have chosen for the function pg_stat_get_db_deadlocks()
is already in use, please choose another one using the unused_oids
script (3150)
- pg_stat_reset() doesn't reset deadlock counter (see
pgstat_recv_resetcounter())

everything else seems fine to me

--
Jaime Casanova         www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Jaime Casanova <jaime(at)2ndquadrant(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stat_database deadlock counter
Date: 2012-01-26 15:03:43
Message-ID: CABUevEyVCAS5gqiNNNWZ_kEcAEUP2ZRCXxSKS41bJujzDAkaGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Jan 22, 2012 at 19:35, Jaime Casanova <jaime(at)2ndquadrant(dot)com> wrote:
> On Mon, Jan 16, 2012 at 3:19 PM, Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>> Attached patch adds a counter for number of deadlocks in a database to
>> pg_stat_database.
>>
>
> A little review:
>
> - it applies with a few hunks
> - the oid you have chosen for the function pg_stat_get_db_deadlocks()
> is already in use, please choose another one using the unused_oids
> script (3150)

yeah, taht always happens..

> - pg_stat_reset() doesn't reset deadlock counter (see
> pgstat_recv_resetcounter())

Good catch, thanks!

I've adjusted the patch for that, resolved the conflicts with the
other pg_stat_database patch, and committed it.

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/