]> granicus.if.org Git - postgresql/commit
Report the current queries of all backends involved in a deadlock
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Mar 2008 21:08:31 +0000 (21:08 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Mar 2008 21:08:31 +0000 (21:08 +0000)
commit4b7ae4afaec67c906ad152ec4795a50f9b235250
treefc55f7a4371da7e9e943f34b06981986ace3b62a
parentdf812e91ada4b9201fedac5bd7277c25b68afb41
Report the current queries of all backends involved in a deadlock
(if they'd be visible to the current user in pg_stat_activity).

This might look like it's subject to race conditions, but it's actually
pretty safe because at the time DeadLockReport() is constructing the
report, we haven't yet aborted our transaction and so we can expect that
everyone else involved in the deadlock is still blocked on some lock.
(There are corner cases where that might not be true, such as a statement
timeout triggering in another backend before we finish reporting; but at
worst we'd report a misleading activity string, so it seems acceptable
considering the usefulness of reporting the queries.)

Original patch by Itagaki Takahiro, heavily modified by me.
src/backend/postmaster/pgstat.c
src/backend/storage/lmgr/deadlock.c
src/include/pgstat.h