1
# name : innodb_show_lock_name.patch
2
# introduced : 11 or before
3
# maintainer : Yasufumi
6
# Any small change to this file in the main branch
7
# should be done or reviewed by the maintainer!
8
--- a/storage/innodb_plugin/handler/ha_innodb.cc
9
+++ b/storage/innodb_plugin/handler/ha_innodb.cc
11
rw_lock_wait_time += mutex->lspent_time;
13
#else /* UNIV_DEBUG */
14
- buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s:%lu",
15
- mutex->cfile_name, (ulong) mutex->cline);
16
+ buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s",
17
+ mutex->cmutex_name);
18
buf2len= (uint) my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
19
(ulong) mutex->count_os_wait);
24
buf1len = (uint) my_snprintf(buf1, sizeof buf1,
26
- block_mutex->cfile_name,
27
- (ulong) block_mutex->cline);
29
+ block_mutex->cmutex_name);
30
buf2len = (uint) my_snprintf(buf2, sizeof buf2,
32
(ulong) block_mutex_oswait_count);
37
- buf1len = my_snprintf(buf1, sizeof buf1, "%s:%lu",
38
- lock->cfile_name, (ulong) lock->cline);
39
+ buf1len = my_snprintf(buf1, sizeof buf1, "%s",
41
buf2len = my_snprintf(buf2, sizeof buf2, "os_waits=%lu",
42
(ulong) lock->count_os_wait);
47
buf1len = (uint) my_snprintf(buf1, sizeof buf1,
49
- block_lock->cfile_name,
50
- (ulong) block_lock->cline);
52
+ block_lock->lock_name);
53
buf2len = (uint) my_snprintf(buf2, sizeof buf2,
55
(ulong) block_lock_oswait_count);
56
--- a/storage/innodb_plugin/handler/innodb_patch_info.h
57
+++ b/storage/innodb_plugin/handler/innodb_patch_info.h
59
{"innodb_recovery_patches","Bugfixes and adjustments about recovery process","","http://www.percona.com/docs/wiki/percona-xtradb"},
60
{"innodb_purge_thread","Enable to use purge devoted thread","","http://www.percona.com/docs/wiki/percona-xtradb"},
61
{"innodb_admin_command_base","XtraDB specific command interface through i_s","","http://www.percona.com/docs/wiki/percona-xtradb"},
62
+{"innodb_show_lock_name","Show mutex/lock name instead of crated file/line","","http://www.percona.com/docs/wiki/percona-xtradb"},
63
{NULL, NULL, NULL, NULL}
65
--- a/storage/innodb_plugin/include/sync0rw.h
66
+++ b/storage/innodb_plugin/include/sync0rw.h
69
# ifdef UNIV_SYNC_DEBUG
70
# define rw_lock_create(L, level) \
71
- rw_lock_create_func((L), (level), #L, __FILE__, __LINE__)
72
+ rw_lock_create_func((L), (level), __FILE__, __LINE__, #L)
73
# else /* UNIV_SYNC_DEBUG */
74
# define rw_lock_create(L, level) \
75
- rw_lock_create_func((L), #L, __FILE__, __LINE__)
76
+ rw_lock_create_func((L), __FILE__, __LINE__, #L)
77
# endif /* UNIV_SYNC_DEBUG */
78
#else /* UNIV_DEBUG */
79
# define rw_lock_create(L, level) \
80
- rw_lock_create_func((L), __FILE__, __LINE__)
81
+ rw_lock_create_func((L), #L)
82
#endif /* UNIV_DEBUG */
84
/******************************************************************//**
86
# ifdef UNIV_SYNC_DEBUG
87
ulint level, /*!< in: level */
88
# endif /* UNIV_SYNC_DEBUG */
89
- const char* cmutex_name, /*!< in: mutex name */
90
-#endif /* UNIV_DEBUG */
91
const char* cfile_name, /*!< in: file name where created */
92
- ulint cline); /*!< in: file line where created */
93
+ ulint cline, /*!< in: file line where created */
94
+#endif /* UNIV_DEBUG */
95
+ const char* cmutex_name); /*!< in: mutex name */
96
/******************************************************************//**
97
Calling this function is obligatory only if the memory buffer containing
98
the rw-lock is freed. Removes an rw-lock object from the global list. The
100
ulint level; /*!< Level in the global latching order. */
101
#endif /* UNIV_SYNC_DEBUG */
102
ulint count_os_wait; /*!< Count of os_waits. May not be accurate */
103
- const char* cfile_name;/*!< File name where lock created */
104
+ //const char* cfile_name;/*!< File name where lock created */
105
+ const char* lock_name;/*!< lock name */
106
/* last s-lock file/line is not guaranteed to be correct */
107
const char* last_s_file_name;/*!< File name where last s-locked */
108
const char* last_x_file_name;/*!< File name where last x-locked */
110
are at the start of this struct, thus we can
111
peek this field without causing much memory
113
- unsigned cline:14; /*!< Line where created */
114
+ //unsigned cline:14; /*!< Line where created */
115
unsigned last_s_line:14; /*!< Line number where last time s-locked */
116
unsigned last_x_line:14; /*!< Line number where last time x-locked */
118
--- a/storage/innodb_plugin/include/sync0sync.h
119
+++ b/storage/innodb_plugin/include/sync0sync.h
122
# ifdef UNIV_SYNC_DEBUG
123
# define mutex_create(M, level) \
124
- mutex_create_func((M), #M, (level), __FILE__, __LINE__)
125
+ mutex_create_func((M), (level), __FILE__, __LINE__, #M)
127
# define mutex_create(M, level) \
128
- mutex_create_func((M), #M, __FILE__, __LINE__)
129
+ mutex_create_func((M), __FILE__, __LINE__, #M)
132
# define mutex_create(M, level) \
133
- mutex_create_func((M), __FILE__, __LINE__)
134
+ mutex_create_func((M), #M)
137
/******************************************************************//**
140
mutex_t* mutex, /*!< in: pointer to memory */
142
- const char* cmutex_name, /*!< in: mutex name */
143
# ifdef UNIV_SYNC_DEBUG
144
ulint level, /*!< in: level */
145
# endif /* UNIV_SYNC_DEBUG */
146
-#endif /* UNIV_DEBUG */
147
const char* cfile_name, /*!< in: file name where created */
148
- ulint cline); /*!< in: file line where created */
149
+ ulint cline, /*!< in: file line where created */
150
+#endif /* UNIV_DEBUG */
151
+ const char* cmutex_name); /*!< in: mutex name */
153
#undef mutex_free /* Fix for MacOS X */
156
ulint line; /*!< Line where the mutex was locked */
157
ulint level; /*!< Level in the global latching order */
158
#endif /* UNIV_SYNC_DEBUG */
160
const char* cfile_name;/*!< File name where mutex created */
161
ulint cline; /*!< Line where created */
163
os_thread_id_t thread_id; /*!< The thread id of the thread
164
which locked the mutex. */
165
ulint magic_n; /*!< MUTEX_MAGIC_N */
167
ulong count_os_yield; /*!< count of os_wait */
168
ulonglong lspent_time; /*!< mutex os_wait timer msec */
169
ulonglong lmax_spent_time;/*!< mutex os_wait timer msec */
170
- const char* cmutex_name; /*!< mutex name */
171
ulint mutex_type; /*!< 0=usual mutex, 1=rw_lock mutex */
172
#endif /* UNIV_DEBUG */
173
+ const char* cmutex_name; /*!< mutex name */
176
/** The global array of wait cells for implementation of the databases own
177
--- a/storage/innodb_plugin/sync/sync0arr.c
178
+++ b/storage/innodb_plugin/sync/sync0arr.c
179
@@ -482,12 +482,12 @@
180
mutex = cell->old_wait_mutex;
183
- "Mutex at %p created file %s line %lu, lock var %lu\n"
184
+ "Mutex at %p '%s', lock var %lu\n"
185
#ifdef UNIV_SYNC_DEBUG
186
"Last time reserved in file %s line %lu, "
187
#endif /* UNIV_SYNC_DEBUG */
188
"waiters flag %lu\n",
189
- (void*) mutex, mutex->cfile_name, (ulong) mutex->cline,
190
+ (void*) mutex, mutex->cmutex_name,
191
(ulong) mutex->lock_word,
192
#ifdef UNIV_SYNC_DEBUG
193
mutex->file_name, (ulong) mutex->line,
195
rwlock = cell->old_wait_rw_lock;
198
- " RW-latch at %p created in file %s line %lu\n",
199
- (void*) rwlock, rwlock->cfile_name,
200
- (ulong) rwlock->cline);
201
+ " RW-latch at %p '%s'\n",
202
+ (void*) rwlock, rwlock->lock_name);
203
writer = rw_lock_get_writer(rwlock);
204
if (writer != RW_LOCK_NOT_LOCKED) {
206
--- a/storage/innodb_plugin/sync/sync0rw.c
207
+++ b/storage/innodb_plugin/sync/sync0rw.c
208
@@ -231,10 +231,10 @@
209
# ifdef UNIV_SYNC_DEBUG
210
ulint level, /*!< in: level */
211
# endif /* UNIV_SYNC_DEBUG */
212
- const char* cmutex_name, /*!< in: mutex name */
213
-#endif /* UNIV_DEBUG */
214
const char* cfile_name, /*!< in: file name where created */
215
- ulint cline) /*!< in: file line where created */
216
+ ulint cline, /*!< in: file line where created */
217
+#endif /* UNIV_DEBUG */
218
+ const char* cmutex_name) /*!< in: mutex name */
220
/* If this is the very first time a synchronization object is
221
created, then the following call initializes the sync system. */
222
@@ -242,14 +242,15 @@
223
#ifndef INNODB_RW_LOCKS_USE_ATOMICS
224
mutex_create(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);
226
- lock->mutex.cfile_name = cfile_name;
227
- lock->mutex.cline = cline;
228
+ ut_d(lock->mutex.cfile_name = cfile_name);
229
+ ut_d(lock->mutex.cline = cline);
231
- ut_d(lock->mutex.cmutex_name = cmutex_name);
232
+ lock->mutex.cmutex_name = cmutex_name;
233
ut_d(lock->mutex.mutex_type = 1);
234
#else /* INNODB_RW_LOCKS_USE_ATOMICS */
236
- UT_NOT_USED(cmutex_name);
237
+ UT_NOT_USED(cfile_name);
238
+ UT_NOT_USED(cline);
240
#endif /* INNODB_RW_LOCKS_USE_ATOMICS */
244
ut_d(lock->magic_n = RW_LOCK_MAGIC_N);
246
- lock->cfile_name = cfile_name;
247
- lock->cline = (unsigned int) cline;
248
+ lock->lock_name = cmutex_name;
250
lock->count_os_wait = 0;
251
lock->last_s_file_name = "not yet reserved";
252
@@ -393,10 +393,10 @@
253
if (srv_print_latch_waits) {
255
"Thread %lu spin wait rw-s-lock at %p"
256
- " cfile %s cline %lu rnds %lu\n",
257
+ " '%s' rnds %lu\n",
258
(ulong) os_thread_pf(os_thread_get_curr_id()),
260
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
261
+ lock->lock_name, (ulong) i);
264
/* We try once again to obtain the lock */
266
if (srv_print_latch_waits) {
268
"Thread %lu OS wait rw-s-lock at %p"
269
- " cfile %s cline %lu\n",
271
os_thread_pf(os_thread_get_curr_id()),
272
- (void*) lock, lock->cfile_name,
273
- (ulong) lock->cline);
274
+ (void*) lock, lock->lock_name);
277
/* these stats may not be accurate */
279
if (srv_print_latch_waits) {
281
"Thread %lu spin wait rw-x-lock at %p"
282
- " cfile %s cline %lu rnds %lu\n",
283
+ " '%s' rnds %lu\n",
284
os_thread_pf(os_thread_get_curr_id()), (void*) lock,
285
- lock->cfile_name, (ulong) lock->cline, (ulong) i);
286
+ lock->lock_name, (ulong) i);
289
sync_array_reserve_cell(sync_primary_wait_array,
291
if (srv_print_latch_waits) {
293
"Thread %lu OS wait for rw-x-lock at %p"
294
- " cfile %s cline %lu\n",
296
os_thread_pf(os_thread_get_curr_id()), (void*) lock,
297
- lock->cfile_name, (ulong) lock->cline);
301
/* these stats may not be accurate */
302
--- a/storage/innodb_plugin/sync/sync0sync.c
303
+++ b/storage/innodb_plugin/sync/sync0sync.c
304
@@ -239,13 +239,13 @@
306
mutex_t* mutex, /*!< in: pointer to memory */
308
- const char* cmutex_name, /*!< in: mutex name */
309
# ifdef UNIV_SYNC_DEBUG
310
ulint level, /*!< in: level */
311
# endif /* UNIV_SYNC_DEBUG */
312
-#endif /* UNIV_DEBUG */
313
const char* cfile_name, /*!< in: file name where created */
314
- ulint cline) /*!< in: file line where created */
315
+ ulint cline, /*!< in: file line where created */
316
+#endif /* UNIV_DEBUG */
317
+ const char* cmutex_name) /*!< in: mutex name */
319
#if defined(HAVE_ATOMIC_BUILTINS)
320
mutex_reset_lock_word(mutex);
321
@@ -263,11 +263,13 @@
322
mutex->file_name = "not yet reserved";
323
mutex->level = level;
324
#endif /* UNIV_SYNC_DEBUG */
326
mutex->cfile_name = cfile_name;
327
mutex->cline = cline;
328
+#endif /* UNIV_DEBUG */
329
mutex->count_os_wait = 0;
331
mutex->cmutex_name= cmutex_name;
333
mutex->count_using= 0;
334
mutex->mutex_type= 0;
335
mutex->lspent_time= 0;
337
#ifdef UNIV_SRV_PRINT_LATCH_WAITS
339
"Thread %lu spin wait mutex at %p"
340
- " cfile %s cline %lu rnds %lu\n",
341
+ " '%s' rnds %lu\n",
342
(ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex,
343
- mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
344
+ mutex->cmutex_name, (ulong) i);
347
mutex_spin_round_count += i;
350
#ifdef UNIV_SRV_PRINT_LATCH_WAITS
352
- "Thread %lu OS wait mutex at %p cfile %s cline %lu rnds %lu\n",
353
+ "Thread %lu OS wait mutex at %p '%s' rnds %lu\n",
354
(ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex,
355
- mutex->cfile_name, (ulong) mutex->cline, (ulong) i);
356
+ mutex->cmutex_name, (ulong) i);
359
mutex_os_wait_count++;
362
if (mutex->magic_n == MUTEX_MAGIC_N) {
364
- "Mutex created at %s %lu\n",
366
- (ulong) mutex->cline);
368
+ mutex->cmutex_name);
370
if (mutex_get_lock_word(mutex) != 0) {
371
const char* file_name;