[Commits] a88c9a6: MDEV-7619: Improve long semaphore wait output

Jan Lindström jan.lindstrom at mariadb.com
Wed Mar 11 07:30:46 EET 2015


revision-id: a88c9a65cccb4fc6c69ccae5c9995dc62ce5f5a3
parent(s): c8035da9b8d037b43c27268b37df40e587780bec
committer: Jan Lindström
branch nick: 10.1
timestamp: 2015-03-11 07:29:51 +0200
message:

MDEV-7619: Improve long semaphore wait output

Add holder thread_id, file_name and line to output.

---
 storage/innobase/sync/sync0arr.cc | 16 ++++++++++------
 storage/xtradb/sync/sync0arr.cc   | 13 +++++++------
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/storage/innobase/sync/sync0arr.cc b/storage/innobase/sync/sync0arr.cc
index e501423..aa0cdfe 100644
--- a/storage/innobase/sync/sync0arr.cc
+++ b/storage/innobase/sync/sync0arr.cc
@@ -500,16 +500,13 @@ sync_array_cell_print(
 		if (mutex) {
 			fprintf(file,
 				"Mutex at %p created file %s line %lu, lock var %lu\n"
-#ifdef UNIV_SYNC_DEBUG
-				"Last time reserved in file %s line %lu, "
-#endif /* UNIV_SYNC_DEBUG */
+				"Last time reserved by thread %lu in file %s line %lu, "
 				"waiters flag %lu\n",
 				(void*) mutex, innobase_basename(mutex->cfile_name),
 				(ulong) mutex->cline,
 				(ulong) mutex->lock_word,
-#ifdef UNIV_SYNC_DEBUG
+				mutex->thread_id,
 				mutex->file_name, (ulong) mutex->line,
-#endif /* UNIV_SYNC_DEBUG */
 				(ulong) mutex->waiters);
 		}
 
@@ -528,8 +525,10 @@ sync_array_cell_print(
 				" RW-latch at %p created in file %s line %lu\n",
 				(void*) rwlock, innobase_basename(rwlock->cfile_name),
 				(ulong) rwlock->cline);
+
 			writer = rw_lock_get_writer(rwlock);
-			if (writer != RW_LOCK_NOT_LOCKED) {
+
+			if (writer && writer != RW_LOCK_NOT_LOCKED) {
 				fprintf(file,
 					"a writer (thread id %lu) has"
 					" reserved it in mode %s",
@@ -552,6 +551,11 @@ sync_array_cell_print(
 				(ulong) rwlock->last_s_line,
 				rwlock->last_x_file_name,
 				(ulong) rwlock->last_x_line);
+
+			fprintf(file,
+				"Holder thread %lu file %s line %lu\n",
+				rwlock->thread_id, rwlock->file_name, rwlock->line);
+
 		}
 	} else {
 		ut_error;
diff --git a/storage/xtradb/sync/sync0arr.cc b/storage/xtradb/sync/sync0arr.cc
index ebabc3d..01cae70 100644
--- a/storage/xtradb/sync/sync0arr.cc
+++ b/storage/xtradb/sync/sync0arr.cc
@@ -522,15 +522,12 @@ sync_array_cell_print(
 		if (mutex) {
 			fprintf(file,
 				"Mutex at %p '%s', lock var %lu\n"
-#ifdef UNIV_SYNC_DEBUG
-				"Last time reserved in file %s line %lu, "
-#endif /* UNIV_SYNC_DEBUG */
+				"Last time reserved by thread %lu in file %s line %lu, "
 				"waiters flag %lu\n",
 				(void*) mutex, mutex->cmutex_name,
 				(ulong) mutex->lock_word,
-#ifdef UNIV_SYNC_DEBUG
+				mutex->thread_id,
 				mutex->file_name, (ulong) mutex->line,
-#endif /* UNIV_SYNC_DEBUG */
 				(ulong) mutex->waiters);
 		}
 
@@ -608,6 +605,10 @@ sync_array_cell_print(
 				rwlock->last_x_file_name,
 				(ulong) rwlock->last_x_line);
 
+			fprintf(file,
+				"Holder thread %lu file %s line %lu\n",
+				rwlock->thread_id, rwlock->file_name, rwlock->line);
+
 			/* If stacktrace feature is enabled we will send a SIGUSR2
 			signal to thread that has locked RW-latch with write mode.
 			Signal handler will then dump the current stack to error log. */
@@ -741,7 +742,7 @@ sync_array_detect_deadlock(
 						       depth);
 			if (ret) {
 				fprintf(stderr,
-			"Mutex %p owned by thread %lu file %s line %lu\n",
+					"Mutex %p owned by thread %lu file %s line %lu\n",
 					mutex, (ulong) os_thread_pf(mutex->thread_id),
 					mutex->file_name, (ulong) mutex->line);
 				sync_array_cell_print(stderr, cell, &r);


More information about the commits mailing list