Christian Kruse wrote:

I think this could use some more comments -- for instance at the top of
the while loop, explain what's its purpose.

>                       if (deadlock_state == DS_SOFT_DEADLOCK)
>                               ereport(LOG,
>                                               (errmsg("process %d avoided 
> deadlock for %s on %s by rearranging queue order after %ld.%03d ms",
> -                                                       MyProcPid, modename, 
> buf.data, msecs, usecs)));
> +                                                             MyProcPid, 
> modename, buf.data, msecs, usecs),
> +                                              (errcontext(ngettext("process 
> owning lock: %s request queue: %s",
> +                                                        "processes owning 
> lock: %s request queue: %s",
> +                                                                             
>           lockHoldersNum), lock_holders_sbuf.data, lock_waiters_sbuf.data))));

This ngettext() call is repeated four times in the new code, which is a
bit annoying because it's not trivial.  I think you could assign the
ngettext() to a char * at the bottom of the loop, and then in the
ereport() calls use it:


char *errcxt = NULL;

while ( ... )
{
        ...
        errcxt = ngettext("processes owning lock: ..");
}

ereport(LOG,
        (errmsg("blah blah"),
         errcxt != NULL ? errcontext(errcxt) : 0));


That would avoid the repetition.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to