~percona-dev/percona-server/release-5.1.49-11

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# name       : innodb_show_lock_name.patch
# introduced : 11 or before
# maintainer : Yasufumi
#
#!!! notice !!!
# Any small change to this file in the main branch
# should be done or reviewed by the maintainer!
diff -Nur a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-10 15:31:28.676992644 +0400
+++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-08-10 15:31:29.176994600 +0400
@@ -9204,8 +9204,8 @@
 			rw_lock_wait_time += mutex->lspent_time;
 		}
 #else /* UNIV_DEBUG */
-		buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s:%lu",
-				     mutex->cfile_name, (ulong) mutex->cline);
+		buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s",
+				     mutex->cmutex_name);
 		buf2len= (uint) my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
 				     (ulong) mutex->count_os_wait);
 
@@ -9220,9 +9220,8 @@
 
 	if (block_mutex) {
 		buf1len = (uint) my_snprintf(buf1, sizeof buf1,
-					     "combined %s:%lu",
-					     block_mutex->cfile_name,
-					     (ulong) block_mutex->cline);
+					     "combined %s",
+					     block_mutex->cmutex_name);
 		buf2len = (uint) my_snprintf(buf2, sizeof buf2,
 					     "os_waits=%lu",
 					     (ulong) block_mutex_oswait_count);
@@ -9251,8 +9250,8 @@
 			continue;
 		}
 
-		buf1len = my_snprintf(buf1, sizeof buf1, "%s:%lu",
-				     lock->cfile_name, (ulong) lock->cline);
+		buf1len = my_snprintf(buf1, sizeof buf1, "%s",
+				     lock->lock_name);
 		buf2len = my_snprintf(buf2, sizeof buf2, "os_waits=%lu",
 				      (ulong) lock->count_os_wait);
 
@@ -9266,9 +9265,8 @@
 
 	if (block_lock) {
 		buf1len = (uint) my_snprintf(buf1, sizeof buf1,
-					     "combined %s:%lu",
-					     block_lock->cfile_name,
-					     (ulong) block_lock->cline);
+					     "combined %s",
+					     block_lock->lock_name);
 		buf2len = (uint) my_snprintf(buf2, sizeof buf2,
 					     "os_waits=%lu",
 					     (ulong) block_lock_oswait_count);
diff -Nur a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
--- a/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-10 15:31:28.676992644 +0400
+++ b/storage/innodb_plugin/handler/innodb_patch_info.h	2010-08-10 15:31:29.536991291 +0400
@@ -39,5 +39,6 @@
 {"innodb_recovery_patches","Bugfixes and adjustments about recovery process","","http://www.percona.com/docs/wiki/percona-xtradb"},
 {"innodb_purge_thread","Enable to use purge devoted thread","","http://www.percona.com/docs/wiki/percona-xtradb"},
 {"innodb_admin_command_base","XtraDB specific command interface through i_s","","http://www.percona.com/docs/wiki/percona-xtradb"},
+{"innodb_show_lock_name","Show mutex/lock name instead of crated file/line","","http://www.percona.com/docs/wiki/percona-xtradb"},
 {NULL, NULL, NULL, NULL}
 };
diff -Nur a/storage/innodb_plugin/include/sync0rw.h b/storage/innodb_plugin/include/sync0rw.h
--- a/storage/innodb_plugin/include/sync0rw.h	2010-08-10 15:31:28.686992801 +0400
+++ b/storage/innodb_plugin/include/sync0rw.h	2010-08-10 15:31:29.897003902 +0400
@@ -120,7 +120,7 @@
 # endif /* UNIV_SYNC_DEBUG */
 #else /* UNIV_DEBUG */
 # define rw_lock_create(L, level) 					\
-	rw_lock_create_func((L), __FILE__, __LINE__)
+	rw_lock_create_func((L), #L, NULL, 0)
 #endif /* UNIV_DEBUG */
 
 /******************************************************************//**
@@ -137,8 +137,8 @@
 # ifdef UNIV_SYNC_DEBUG
 	ulint		level,		/*!< in: level */
 # endif /* UNIV_SYNC_DEBUG */
-	const char*	cmutex_name, 	/*!< in: mutex name */
 #endif /* UNIV_DEBUG */
+	const char*	cmutex_name, 	/*!< in: mutex name */
 	const char*	cfile_name,	/*!< in: file name where created */
 	ulint 		cline);		/*!< in: file line where created */
 /******************************************************************//**
@@ -541,7 +541,8 @@
 	ulint	level;		/*!< Level in the global latching order. */
 #endif /* UNIV_SYNC_DEBUG */
 	ulint count_os_wait;	/*!< Count of os_waits. May not be accurate */
-	const char*	cfile_name;/*!< File name where lock created */
+	//const char*	cfile_name;/*!< File name where lock created */
+	const char*	lock_name;/*!< lock name */
         /* last s-lock file/line is not guaranteed to be correct */
 	const char*	last_s_file_name;/*!< File name where last s-locked */
 	const char*	last_x_file_name;/*!< File name where last x-locked */
@@ -552,7 +553,7 @@
 				are at the start of this struct, thus we can
 				peek this field without causing much memory
 				bus traffic */
-	unsigned	cline:14;	/*!< Line where created */
+	//unsigned	cline:14;	/*!< Line where created */
 	unsigned	last_s_line:14;	/*!< Line number where last time s-locked */
 	unsigned	last_x_line:14;	/*!< Line number where last time x-locked */
 #ifdef UNIV_DEBUG
diff -Nur a/storage/innodb_plugin/include/sync0sync.h b/storage/innodb_plugin/include/sync0sync.h
--- a/storage/innodb_plugin/include/sync0sync.h	2010-08-10 15:31:28.686992801 +0400
+++ b/storage/innodb_plugin/include/sync0sync.h	2010-08-10 15:31:32.076992476 +0400
@@ -80,7 +80,7 @@
 # endif
 #else
 # define mutex_create(M, level)					\
-	mutex_create_func((M), __FILE__, __LINE__)
+	mutex_create_func((M), #M, NULL, 0)
 #endif
 
 /******************************************************************//**
@@ -93,8 +93,8 @@
 mutex_create_func(
 /*==============*/
 	mutex_t*	mutex,		/*!< in: pointer to memory */
-#ifdef UNIV_DEBUG
 	const char*	cmutex_name,	/*!< in: mutex name */
+#ifdef UNIV_DEBUG
 # ifdef UNIV_SYNC_DEBUG
 	ulint		level,		/*!< in: level */
 # endif /* UNIV_SYNC_DEBUG */
@@ -536,9 +536,9 @@
 	ulint	line;		/*!< Line where the mutex was locked */
 	ulint	level;		/*!< Level in the global latching order */
 #endif /* UNIV_SYNC_DEBUG */
+#ifdef UNIV_DEBUG
 	const char*	cfile_name;/*!< File name where mutex created */
 	ulint		cline;	/*!< Line where created */
-#ifdef UNIV_DEBUG
 	os_thread_id_t thread_id; /*!< The thread id of the thread
 				which locked the mutex. */
 	ulint		magic_n;	/*!< MUTEX_MAGIC_N */
@@ -553,9 +553,9 @@
 	ulong		count_os_yield;	/*!< count of os_wait */
 	ulonglong	lspent_time;	/*!< mutex os_wait timer msec */
 	ulonglong	lmax_spent_time;/*!< mutex os_wait timer msec */
-	const char*	cmutex_name;	/*!< mutex name */
 	ulint		mutex_type;	/*!< 0=usual mutex, 1=rw_lock mutex */
 #endif /* UNIV_DEBUG */
+	const char*	cmutex_name;	/*!< mutex name */
 };
 
 /** The global array of wait cells for implementation of the databases own
diff -Nur a/storage/innodb_plugin/sync/sync0arr.c b/storage/innodb_plugin/sync/sync0arr.c
--- a/storage/innodb_plugin/sync/sync0arr.c	2010-08-10 15:31:28.676992644 +0400
+++ b/storage/innodb_plugin/sync/sync0arr.c	2010-08-10 15:31:32.297203764 +0400
@@ -482,12 +482,12 @@
 		mutex = cell->old_wait_mutex;
 
 		fprintf(file,
-			"Mutex at %p created file %s line %lu, lock var %lu\n"
+			"Mutex at %p '%s', lock var %lu\n"
 #ifdef UNIV_SYNC_DEBUG
 			"Last time reserved in file %s line %lu, "
 #endif /* UNIV_SYNC_DEBUG */
 			"waiters flag %lu\n",
-			(void*) mutex, mutex->cfile_name, (ulong) mutex->cline,
+			(void*) mutex, mutex->cmutex_name,
 			(ulong) mutex->lock_word,
 #ifdef UNIV_SYNC_DEBUG
 			mutex->file_name, (ulong) mutex->line,
@@ -505,9 +505,8 @@
 		rwlock = cell->old_wait_rw_lock;
 
 		fprintf(file,
-			" RW-latch at %p created in file %s line %lu\n",
-			(void*) rwlock, rwlock->cfile_name,
-			(ulong) rwlock->cline);
+			" RW-latch at %p '%s'\n",
+			(void*) rwlock, rwlock->lock_name);
 		writer = rw_lock_get_writer(rwlock);
 		if (writer != RW_LOCK_NOT_LOCKED) {
 			fprintf(file,
diff -Nur a/storage/innodb_plugin/sync/sync0rw.c b/storage/innodb_plugin/sync/sync0rw.c
--- a/storage/innodb_plugin/sync/sync0rw.c	2010-08-10 15:31:28.676992644 +0400
+++ b/storage/innodb_plugin/sync/sync0rw.c	2010-08-10 15:31:33.436991679 +0400
@@ -231,8 +231,8 @@
 # ifdef UNIV_SYNC_DEBUG
 	ulint		level,		/*!< in: level */
 # endif /* UNIV_SYNC_DEBUG */
-	const char*	cmutex_name, 	/*!< in: mutex name */
 #endif /* UNIV_DEBUG */
+	const char*	cmutex_name, 	/*!< in: mutex name */
 	const char*	cfile_name,	/*!< in: file name where created */
 	ulint		cline)		/*!< in: file line where created */
 {
@@ -242,14 +242,15 @@
 #ifndef INNODB_RW_LOCKS_USE_ATOMICS
 	mutex_create(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
 
-	lock->mutex.cfile_name = cfile_name;
-	lock->mutex.cline = cline;
+	ut_d(lock->mutex.cfile_name = cfile_name);
+	ut_d(lock->mutex.cline = cline);
 
-	ut_d(lock->mutex.cmutex_name = cmutex_name);
+	lock->mutex.cmutex_name = cmutex_name;
 	ut_d(lock->mutex.mutex_type = 1);
 #else /* INNODB_RW_LOCKS_USE_ATOMICS */
 # ifdef UNIV_DEBUG
-	UT_NOT_USED(cmutex_name);
+	UT_NOT_USED(cfile_name);
+	UT_NOT_USED(cline);
 # endif
 #endif /* INNODB_RW_LOCKS_USE_ATOMICS */
 
@@ -269,8 +270,7 @@
 
 	ut_d(lock->magic_n = RW_LOCK_MAGIC_N);
 
-	lock->cfile_name = cfile_name;
-	lock->cline = (unsigned int) cline;
+	lock->lock_name = cmutex_name;
 
 	lock->count_os_wait = 0;
 	lock->last_s_file_name = "not yet reserved";
@@ -387,10 +387,10 @@
 	if (srv_print_latch_waits) {
 		fprintf(stderr,
 			"Thread %lu spin wait rw-s-lock at %p"
-			" cfile %s cline %lu rnds %lu\n",
+			" '%s' rnds %lu\n",
 			(ulong) os_thread_pf(os_thread_get_curr_id()),
 			(void*) lock,
-			lock->cfile_name, (ulong) lock->cline, (ulong) i);
+			lock->lock_name, (ulong) i);
 	}
 
 	/* We try once again to obtain the lock */
@@ -423,10 +423,9 @@
 		if (srv_print_latch_waits) {
 			fprintf(stderr,
 				"Thread %lu OS wait rw-s-lock at %p"
-				" cfile %s cline %lu\n",
+				" '%s'\n",
 				os_thread_pf(os_thread_get_curr_id()),
-				(void*) lock, lock->cfile_name,
-				(ulong) lock->cline);
+				(void*) lock, lock->lock_name);
 		}
 
 		/* these stats may not be accurate */
@@ -645,9 +644,9 @@
 	if (srv_print_latch_waits) {
 		fprintf(stderr,
 			"Thread %lu spin wait rw-x-lock at %p"
-			" cfile %s cline %lu rnds %lu\n",
+			" '%s' rnds %lu\n",
 			os_thread_pf(os_thread_get_curr_id()), (void*) lock,
-			lock->cfile_name, (ulong) lock->cline, (ulong) i);
+			lock->lock_name, (ulong) i);
 	}
 
 	sync_array_reserve_cell(sync_primary_wait_array,
@@ -668,9 +667,9 @@
 	if (srv_print_latch_waits) {
 		fprintf(stderr,
 			"Thread %lu OS wait for rw-x-lock at %p"
-			" cfile %s cline %lu\n",
+			" '%s'\n",
 			os_thread_pf(os_thread_get_curr_id()), (void*) lock,
-			lock->cfile_name, (ulong) lock->cline);
+			lock->lock_name);
 	}
 
 	/* these stats may not be accurate */
diff -Nur a/storage/innodb_plugin/sync/sync0sync.c b/storage/innodb_plugin/sync/sync0sync.c
--- a/storage/innodb_plugin/sync/sync0sync.c	2010-08-10 15:31:28.676992644 +0400
+++ b/storage/innodb_plugin/sync/sync0sync.c	2010-08-10 15:31:34.526992531 +0400
@@ -238,8 +238,8 @@
 mutex_create_func(
 /*==============*/
 	mutex_t*	mutex,		/*!< in: pointer to memory */
-#ifdef UNIV_DEBUG
 	const char*	cmutex_name,	/*!< in: mutex name */
+#ifdef UNIV_DEBUG
 # ifdef UNIV_SYNC_DEBUG
 	ulint		level,		/*!< in: level */
 # endif /* UNIV_SYNC_DEBUG */
@@ -263,11 +263,13 @@
 	mutex->file_name = "not yet reserved";
 	mutex->level = level;
 #endif /* UNIV_SYNC_DEBUG */
+#ifdef UNIV_DEBUG
 	mutex->cfile_name = cfile_name;
 	mutex->cline = cline;
+#endif /* UNIV_DEBUG */
 	mutex->count_os_wait = 0;
-#ifdef UNIV_DEBUG
 	mutex->cmutex_name=	  cmutex_name;
+#ifdef UNIV_DEBUG
 	mutex->count_using=	  0;
 	mutex->mutex_type=	  0;
 	mutex->lspent_time=	  0;
@@ -520,9 +522,9 @@
 #ifdef UNIV_SRV_PRINT_LATCH_WAITS
 	fprintf(stderr,
 		"Thread %lu spin wait mutex at %p"
-		" cfile %s cline %lu rnds %lu\n",
+		" '%s' rnds %lu\n",
 		(ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex,
-		mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
+		mutex->cmutex_name, (ulong) i);
 #endif
 
 	mutex_spin_round_count += i;
@@ -597,9 +599,9 @@
 
 #ifdef UNIV_SRV_PRINT_LATCH_WAITS
 	fprintf(stderr,
-		"Thread %lu OS wait mutex at %p cfile %s cline %lu rnds %lu\n",
+		"Thread %lu OS wait mutex at %p '%s' rnds %lu\n",
 		(ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex,
-		mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
+		mutex->cmutex_name, (ulong) i);
 #endif
 
 	mutex_os_wait_count++;
@@ -901,9 +903,8 @@
 
 				if (mutex->magic_n == MUTEX_MAGIC_N) {
 					fprintf(stderr,
-						"Mutex created at %s %lu\n",
-						mutex->cfile_name,
-						(ulong) mutex->cline);
+						"Mutex '%s'\n",
+						mutex->cmutex_name);
 
 					if (mutex_get_lock_word(mutex) != 0) {
 						const char*	file_name;