Only log 'process acquired lock' if we actually did get the lock. This
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Jun 2007 22:01:15 +0000 (22:01 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 19 Jun 2007 22:01:15 +0000 (22:01 +0000)
test seems inessential right now since the only control path for not
getting the lock is via CHECK_FOR_INTERRUPTS which won't return control
to ProcSleep, but it would be important if we ever allow the deadlock
code to kill someone else's transaction instead of our own.

src/backend/storage/lmgr/proc.c

index 6b98962b3c2f1dd219bdb3e9d7d72ba43cfe3057..236ab03579e3c0278bd6faf686579f705e903707 100644 (file)
@@ -887,7 +887,7 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
                        switch (deadlock_state)
                        {
                                case DS_NOT_YET_CHECKED:
-                                       /* Spurious wakeup as described above */
+                                       /* Lock granted, or spurious wakeup as described above */
                                        break; 
                                case DS_NO_DEADLOCK:
                                case DS_SOFT_DEADLOCK:
@@ -918,16 +918,17 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
                                                                (errmsg("process %d still waiting for %s on %s after %ld.%03d ms",
                                                                                MyProcPid, modename, buf.data,
                                                                                msecs, usecs)));
-                                       else
+                                       else if (MyProc->waitStatus == STATUS_OK)
                                                ereport(LOG,
                                                                (errmsg("process %d acquired %s on %s after %ld.%03d ms",
                                                                                MyProcPid, modename, buf.data,
                                                                                msecs, usecs)));
+                                       /* ERROR will be reported later, so no message here */
                                        pfree(buf.data);
                                        break;
                                }
                                case DS_HARD_DEADLOCK:
-                                       /* ERROR will be reported below, so no message here */
+                                       /* ERROR will be reported later, so no message here */
                                        break; 
                        }
                }