Re: Improving deadlock error messages

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: Improving deadlock error messages
Дата
Msg-id 1177192609.16415.107.camel@localhost.localdomain
обсуждение исходный текст
Ответ на Re: Improving deadlock error messages  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Improving deadlock error messages  (Neil Conway <neilc@samurai.com>)
Список pgsql-hackers
On Sat, 2007-04-21 at 02:38 -0400, Tom Lane wrote:
> Maybe so, but you're going to be writing quite a lot of duplicative
> code, because the existing routines you might have been thinking of
> using (lsyscache.c etc) don't behave that way.

Right, I'm envisioning doing a conditional LockAcquire and then
heap_open() / heap_getnext() by hand. That will be relatively slow, but
code that emits a deadlock error message is almost by definition not
performance critical.

BTW, another alternative would be to set a global variable instructing
LockAcquire() to not block waiting for a lock; instead, it would
longjmp(), a la elog(ERROR). You could even construct something similar
to PG_TRY():

PG_COND_LOCK();
{   /* do various things that might acquire lmgr locks */
}
PG_ACQUIRE_FAILED()
{   /* failed to acquire an lmgr lock */
}
PG_END_COND_LOCK();

The risk would be leaving the LockAcquire() call site in an inconsistent
state when we longjmp(), but since DeadLockReport() is going to
ereport(ERROR) anyway, it might be sufficiently safe. This scheme does
seem a bit fragile, though...

-Neil




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

Предыдущее
От: "Gustavo Tonini"
Дата:
Сообщение: Re: Fragmentation project
Следующее
От: Neil Conway
Дата:
Сообщение: Re: Improving deadlock error messages