Re: Patch: Show process IDs of processes holding a lock; show relation and tuple infos of a lock to acquire

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: Patch: Show process IDs of processes holding a lock; show relation and tuple infos of a lock to acquire
Дата
Msg-id 20140122161729.GO10723@eldon.alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: Patch: Show process IDs of processes holding a lock; show relation and tuple infos of a lock to acquire  (Christian Kruse <christian@2ndquadrant.com>)
Ответы Re: Patch: Show process IDs of processes holding a lock; show relation and tuple infos of a lock to acquire  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Christian Kruse
Дата:
Сообщение: Re: Patch: Show process IDs of processes holding a lock; show relation and tuple infos of a lock to acquire
Следующее
От: Andres Freund
Дата:
Сообщение: WAL replay should fdatasync() segments?