aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/deadlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/lmgr/deadlock.c')
-rw-r--r--src/backend/storage/lmgr/deadlock.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c
index cad85e9d8a0..e1a66456f54 100644
--- a/src/backend/storage/lmgr/deadlock.c
+++ b/src/backend/storage/lmgr/deadlock.c
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.51 2008/01/01 19:45:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/storage/lmgr/deadlock.c,v 1.52 2008/03/21 21:08:31 tgl Exp $
*
* Interface:
*
@@ -26,6 +26,7 @@
#include "postgres.h"
#include "miscadmin.h"
+#include "pgstat.h"
#include "storage/lmgr.h"
#include "storage/proc.h"
#include "utils/memutils.h"
@@ -878,12 +879,14 @@ PrintLockQueue(LOCK *lock, const char *info)
void
DeadLockReport(void)
{
- StringInfoData buf;
- StringInfoData buf2;
+ StringInfoData detailbuf;
+ StringInfoData contextbuf;
+ StringInfoData locktagbuf;
int i;
- initStringInfo(&buf);
- initStringInfo(&buf2);
+ initStringInfo(&detailbuf);
+ initStringInfo(&contextbuf);
+ initStringInfo(&locktagbuf);
for (i = 0; i < nDeadlockDetails; i++)
{
@@ -896,26 +899,36 @@ DeadLockReport(void)
else
nextpid = deadlockDetails[0].pid;
- if (i > 0)
- appendStringInfoChar(&buf, '\n');
+ /* reset locktagbuf to hold next object description */
+ resetStringInfo(&locktagbuf);
- /* reset buf2 to hold next object description */
- resetStringInfo(&buf2);
+ DescribeLockTag(&locktagbuf, &info->locktag);
- DescribeLockTag(&buf2, &info->locktag);
+ if (i > 0)
+ appendStringInfoChar(&detailbuf, '\n');
- appendStringInfo(&buf,
+ appendStringInfo(&detailbuf,
_("Process %d waits for %s on %s; blocked by process %d."),
info->pid,
GetLockmodeName(info->locktag.locktag_lockmethodid,
info->lockmode),
- buf2.data,
+ locktagbuf.data,
nextpid);
+
+ if (i > 0)
+ appendStringInfoChar(&contextbuf, '\n');
+
+ appendStringInfo(&contextbuf,
+ _("Process %d: %s"),
+ info->pid,
+ pgstat_get_backend_current_activity(info->pid));
}
+
ereport(ERROR,
(errcode(ERRCODE_T_R_DEADLOCK_DETECTED),
errmsg("deadlock detected"),
- errdetail("%s", buf.data)));
+ errdetail("%s", detailbuf.data),
+ errcontext("%s", contextbuf.data)));
}
/*