1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

Error message editing in backend/storage.

This commit is contained in:
Tom Lane
2003-07-24 22:04:15 +00:00
parent 658fca8d3a
commit cfa191f3b8
25 changed files with 425 additions and 320 deletions

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.20 2003/03/31 20:32:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.21 2003/07/24 22:04:13 tgl Exp $
*
* Interface:
*
@@ -25,6 +25,7 @@
*/
#include "postgres.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "storage/proc.h"
#include "utils/memutils.h"
@@ -224,7 +225,7 @@ DeadLockCheck(PGPROC *proc)
nWaitOrders = 0;
if (!FindLockCycle(proc, possibleConstraints, &nSoftEdges))
elog(FATAL, "DeadLockCheck: deadlock seems to have disappeared");
elog(FATAL, "deadlock seems to have disappeared");
return true; /* cannot find a non-deadlocked state */
}
@@ -309,7 +310,7 @@ DeadLockCheckRecurse(PGPROC *proc)
{
/* Regenerate the list of possible added constraints */
if (nEdges != TestConfiguration(proc))
elog(FATAL, "DeadLockCheckRecurse: inconsistent results");
elog(FATAL, "inconsistent results during deadlock check");
}
curConstraints[nCurConstraints] =
possibleConstraints[oldPossibleConstraints + i];
@@ -837,13 +838,15 @@ PrintLockQueue(LOCK *lock, const char *info)
#endif
/*
* Report details about a detected deadlock.
* Report a detected deadlock, with available details.
*/
void
DeadLockReport(void)
{
StringInfoData buf;
int i;
initStringInfo(&buf);
for (i = 0; i < nDeadlockDetails; i++)
{
DEADLOCK_INFO *info = &deadlockDetails[i];
@@ -855,26 +858,35 @@ DeadLockReport(void)
else
nextpid = deadlockDetails[0].pid;
if (i > 0)
appendStringInfoChar(&buf, '\n');
if (info->locktag.relId == XactLockTableId && info->locktag.dbId == 0)
{
/* Lock is for transaction ID */
elog(NOTICE, "Proc %d waits for %s on transaction %u; blocked by %d",
info->pid,
GetLockmodeName(info->lockmode),
info->locktag.objId.xid,
nextpid);
appendStringInfo(&buf,
gettext("Proc %d waits for %s on transaction %u; blocked by proc %d."),
info->pid,
GetLockmodeName(info->lockmode),
info->locktag.objId.xid,
nextpid);
}
else
{
/* Lock is for a relation */
elog(NOTICE, "Proc %d waits for %s on relation %u database %u; blocked by %d",
info->pid,
GetLockmodeName(info->lockmode),
info->locktag.relId,
info->locktag.dbId,
nextpid);
appendStringInfo(&buf,
gettext("Proc %d waits for %s on relation %u of database %u; blocked by proc %d."),
info->pid,
GetLockmodeName(info->lockmode),
info->locktag.relId,
info->locktag.dbId,
nextpid);
}
}
ereport(ERROR,
(errcode(ERRCODE_T_R_DEADLOCK_DETECTED),
errmsg("deadlock detected"),
errdetail("%s", buf.data)));
}
/*