Re: Notice lock waits

From: Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Notice lock waits
Date: 2016-08-05 18:53:29
Message-ID: c4883fec-26ed-2b2e-7270-4b773902f2b9@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 05/08/2016 19:00, Jeff Janes wrote:
> One time too many, I ran some minor change using psql on a production
> server and was wondering why it was taking so much longer than it did
> on the test server. Only to discover, after messing around with
> opening new windows and running queries against pg_stat_activity and
> pg_locks and so on, that it was waiting for a lock.
>
> So I created a new guc, notice_lock_waits, which acts like
> log_lock_waits but sends the message as NOTICE so it will show up on
> interactive connections like psql.
>
> I turn it on in my .psqlrc, as it doesn't make much sense for me to
> turn it on in non-interactive sessions.
>
> A general facility for promoting selected LOG messages to NOTICE would
> be nice, but I don't know how to design or implement that. This is
> much easier, and I find it quite useful.
>
> I have it PGC_SUSET because it does send some tiny amount of
> information about the blocking process (the PID) to the blocked
> process. That is probably too paranoid, because the PID can be seen
> by anyone in the pg_locks table anyway.
>
> Do you think this is useful and generally implemented in the correct
> way? If so, I'll try to write some sgml documentation for it.
>

I really like the idea.

I'm not really sure on current implementation. Unless I'm wrong,
disabling log_lock_waits would also disable notice_lock_waits, even if
it's on.

Maybe a new value for log_lock_waits, like "interactive". If switching
this GUC from bool to enum is not acceptable or allowing to see blocking
PID for anyone is an issue, then maybe adding a new GUC to say to also
send a NOTICE instead?

--
Julien Rouhaud
http://dalibo.com - http://dalibo.org

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-08-05 19:17:28 Re: Notice lock waits
Previous Message Bruce Momjian 2016-08-05 18:41:48 Re: pg_size_pretty, SHOW, and spaces