diff --git a/src/backend/storage/ipc/latch.c b/src/backend/storage/ipc/latch.c
index 78c6a89271..07b8273a7d 100644
--- a/src/backend/storage/ipc/latch.c
+++ b/src/backend/storage/ipc/latch.c
@@ -402,6 +402,8 @@ InitSharedLatch(Latch *latch)
 void
 OwnLatch(Latch *latch)
 {
+	pid_t		previous_owner;
+
 	/* Sanity checks */
 	Assert(latch->is_shared);
 
@@ -410,8 +412,11 @@ OwnLatch(Latch *latch)
 	Assert(selfpipe_readfd >= 0 && selfpipe_owner_pid == MyProcPid);
 #endif
 
-	if (latch->owner_pid != 0)
-		elog(ERROR, "latch already owned");
+	previous_owner = latch->owner_pid;
+	if (previous_owner != 0)
+		elog(ERROR,
+			 "latch already owned by PID %lu",
+			 (unsigned long) previous_owner);
 
 	latch->owner_pid = MyProcPid;
 }
