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/innobase/handler/ha_innodb.cc
9 +++ b/storage/innobase/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 - innobase_basename(mutex->cfile_name),
16 - (ulong) mutex->cline);
17 + buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s",
18 + mutex->cmutex_name);
19 buf2len= (uint) my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
20 (ulong) mutex->count_os_wait);
22 @@ -9726,10 +9725,8 @@
25 buf1len = (uint) my_snprintf(buf1, sizeof buf1,
28 - block_mutex->cfile_name),
29 - (ulong) block_mutex->cline);
31 + block_mutex->cmutex_name);
32 buf2len = (uint) my_snprintf(buf2, sizeof buf2,
34 (ulong) block_mutex_oswait_count);
39 - buf1len = my_snprintf(buf1, sizeof buf1, "%s:%lu",
40 - innobase_basename(lock->cfile_name),
41 - (ulong) lock->cline);
42 + buf1len = my_snprintf(buf1, sizeof buf1, "%s",
44 buf2len = my_snprintf(buf2, sizeof buf2, "os_waits=%lu",
45 (ulong) lock->count_os_wait);
47 @@ -9774,10 +9770,8 @@
50 buf1len = (uint) my_snprintf(buf1, sizeof buf1,
53 - block_lock->cfile_name),
54 - (ulong) block_lock->cline);
56 + block_lock->lock_name);
57 buf2len = (uint) my_snprintf(buf2, sizeof buf2,
59 (ulong) block_lock_oswait_count);
60 --- a/storage/innobase/include/sync0rw.h
61 +++ b/storage/innobase/include/sync0rw.h
64 # ifdef UNIV_SYNC_DEBUG
65 # define rw_lock_create(K, L, level) \
66 - rw_lock_create_func((L), (level), #L, __FILE__, __LINE__)
67 + rw_lock_create_func((L), (level), __FILE__, __LINE__, #L)
68 # else /* UNIV_SYNC_DEBUG */
69 # define rw_lock_create(K, L, level) \
70 - rw_lock_create_func((L), #L, __FILE__, __LINE__)
71 + rw_lock_create_func((L), __FILE__, __LINE__, #L)
72 # endif/* UNIV_SYNC_DEBUG */
73 # else /* UNIV_DEBUG */
74 # define rw_lock_create(K, L, level) \
75 - rw_lock_create_func((L), __FILE__, __LINE__)
76 + rw_lock_create_func((L), #L)
77 # endif /* UNIV_DEBUG */
79 /**************************************************************//**
82 # ifdef UNIV_SYNC_DEBUG
83 # define rw_lock_create(K, L, level) \
84 - pfs_rw_lock_create_func((K), (L), (level), #L, __FILE__, __LINE__)
85 + pfs_rw_lock_create_func((K), (L), (level), __FILE__, __LINE__, #L)
86 # else /* UNIV_SYNC_DEBUG */
87 # define rw_lock_create(K, L, level) \
88 - pfs_rw_lock_create_func((K), (L), #L, __FILE__, __LINE__)
89 + pfs_rw_lock_create_func((K), (L), __FILE__, __LINE__, #L)
90 # endif/* UNIV_SYNC_DEBUG */
91 # else /* UNIV_DEBUG */
92 # define rw_lock_create(K, L, level) \
93 - pfs_rw_lock_create_func((K), (L), __FILE__, __LINE__)
94 + pfs_rw_lock_create_func((K), (L), #L)
95 # endif /* UNIV_DEBUG */
97 /******************************************************************
99 # ifdef UNIV_SYNC_DEBUG
100 ulint level, /*!< in: level */
101 # endif /* UNIV_SYNC_DEBUG */
102 - const char* cmutex_name, /*!< in: mutex name */
103 -#endif /* UNIV_DEBUG */
104 const char* cfile_name, /*!< in: file name where created */
105 - ulint cline); /*!< in: file line where created */
106 + ulint cline, /*!< in: file line where created */
107 +#endif /* UNIV_DEBUG */
108 + const char* cmutex_name); /*!< in: mutex name */
109 /******************************************************************//**
110 Calling this function is obligatory only if the memory buffer containing
111 the rw-lock is freed. Removes an rw-lock object from the global list. The
113 struct PSI_rwlock *pfs_psi;/*!< The instrumentation hook */
115 ulint count_os_wait; /*!< Count of os_waits. May not be accurate */
116 - const char* cfile_name;/*!< File name where lock created */
117 + //const char* cfile_name;/*!< File name where lock created */
118 + const char* lock_name;/*!< lock name */
119 /* last s-lock file/line is not guaranteed to be correct */
120 const char* last_s_file_name;/*!< File name where last s-locked */
121 const char* last_x_file_name;/*!< File name where last x-locked */
123 are at the start of this struct, thus we can
124 peek this field without causing much memory
126 - unsigned cline:14; /*!< Line where created */
127 + //unsigned cline:14; /*!< Line where created */
128 unsigned last_s_line:14; /*!< Line number where last time s-locked */
129 unsigned last_x_line:14; /*!< Line number where last time x-locked */
131 @@ -693,10 +694,10 @@
132 # ifdef UNIV_SYNC_DEBUG
133 ulint level, /*!< in: level */
134 # endif /* UNIV_SYNC_DEBUG */
135 - const char* cmutex_name, /*!< in: mutex name */
136 -#endif /* UNIV_DEBUG */
137 const char* cfile_name, /*!< in: file name where created */
138 - ulint cline); /*!< in: file line where created */
139 + ulint cline, /*!< in: file line where created */
140 +#endif /* UNIV_DEBUG */
141 + const char* cmutex_name); /*!< in: mutex name */
143 /******************************************************************//**
144 Performance schema instrumented wrap function for rw_lock_x_lock_func()
145 --- a/storage/innobase/include/sync0rw.ic
146 +++ b/storage/innobase/include/sync0rw.ic
147 @@ -641,10 +641,10 @@
148 # ifdef UNIV_SYNC_DEBUG
149 ulint level, /*!< in: level */
150 # endif /* UNIV_SYNC_DEBUG */
151 - const char* cmutex_name, /*!< in: mutex name */
152 -# endif /* UNIV_DEBUG */
153 const char* cfile_name, /*!< in: file name where created */
154 - ulint cline) /*!< in: file line where created */
155 + ulint cline, /*!< in: file line where created */
156 +# endif /* UNIV_DEBUG */
157 + const char* cmutex_name) /*!< in: mutex name */
159 /* Initialize the rwlock for performance schema */
160 lock->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key))
161 @@ -657,10 +657,10 @@
162 # ifdef UNIV_SYNC_DEBUG
164 # endif /* UNIV_SYNC_DEBUG */
166 -# endif /* UNIV_DEBUG */
170 +# endif /* UNIV_DEBUG */
173 /******************************************************************//**
174 Performance schema instrumented wrap function for rw_lock_x_lock_func()
175 --- a/storage/innobase/include/sync0sync.h
176 +++ b/storage/innobase/include/sync0sync.h
177 @@ -158,14 +158,14 @@
179 # ifdef UNIV_SYNC_DEBUG
180 # define mutex_create(K, M, level) \
181 - pfs_mutex_create_func((K), (M), #M, (level), __FILE__, __LINE__)
182 + pfs_mutex_create_func((K), (M), (level), __FILE__, __LINE__, #M)
184 # define mutex_create(K, M, level) \
185 - pfs_mutex_create_func((K), (M), #M, __FILE__, __LINE__)
186 + pfs_mutex_create_func((K), (M), __FILE__, __LINE__, #M)
187 # endif/* UNIV_SYNC_DEBUG */
189 # define mutex_create(K, M, level) \
190 - pfs_mutex_create_func((K), (M), __FILE__, __LINE__)
191 + pfs_mutex_create_func((K), (M), #M)
192 # endif /* UNIV_DEBUG */
194 # define mutex_enter(M) \
195 @@ -185,14 +185,14 @@
197 # ifdef UNIV_SYNC_DEBUG
198 # define mutex_create(K, M, level) \
199 - mutex_create_func((M), #M, (level), __FILE__, __LINE__)
200 + mutex_create_func((M), (level), __FILE__, __LINE__, #M)
201 # else /* UNIV_SYNC_DEBUG */
202 # define mutex_create(K, M, level) \
203 - mutex_create_func((M), #M, __FILE__, __LINE__)
204 + mutex_create_func((M), __FILE__, __LINE__, #M)
205 # endif /* UNIV_SYNC_DEBUG */
206 # else /* UNIV_DEBUG */
207 # define mutex_create(K, M, level) \
208 - mutex_create_func((M), __FILE__, __LINE__)
209 + mutex_create_func((M), #M)
210 # endif /* UNIV_DEBUG */
212 # define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__)
213 @@ -217,13 +217,13 @@
215 mutex_t* mutex, /*!< in: pointer to memory */
217 - const char* cmutex_name, /*!< in: mutex name */
218 # ifdef UNIV_SYNC_DEBUG
219 ulint level, /*!< in: level */
220 # endif /* UNIV_SYNC_DEBUG */
221 -#endif /* UNIV_DEBUG */
222 const char* cfile_name, /*!< in: file name where created */
223 - ulint cline); /*!< in: file line where created */
224 + ulint cline, /*!< in: file line where created */
225 +#endif /* UNIV_DEBUG */
226 + const char* cmutex_name); /*!< in: mutex name */
228 /******************************************************************//**
229 NOTE! Use the corresponding macro mutex_free(), not directly this function!
230 @@ -291,13 +291,13 @@
231 PSI_mutex_key key, /*!< in: Performance Schema key */
232 mutex_t* mutex, /*!< in: pointer to memory */
234 - const char* cmutex_name, /*!< in: mutex name */
235 # ifdef UNIV_SYNC_DEBUG
236 ulint level, /*!< in: level */
237 # endif /* UNIV_SYNC_DEBUG */
238 -# endif /* UNIV_DEBUG */
239 const char* cfile_name, /*!< in: file name where created */
240 - ulint cline); /*!< in: file line where created */
241 + ulint cline, /*!< in: file line where created */
242 +# endif /* UNIV_DEBUG */
243 + const char* cmutex_name);
244 /******************************************************************//**
245 NOTE! Please use the corresponding macro mutex_enter(), not directly
248 ulint line; /*!< Line where the mutex was locked */
249 ulint level; /*!< Level in the global latching order */
250 #endif /* UNIV_SYNC_DEBUG */
252 const char* cfile_name;/*!< File name where mutex created */
253 ulint cline; /*!< Line where created */
255 os_thread_id_t thread_id; /*!< The thread id of the thread
256 which locked the mutex. */
257 ulint magic_n; /*!< MUTEX_MAGIC_N */
259 ulong count_os_yield; /*!< count of os_wait */
260 ulonglong lspent_time; /*!< mutex os_wait timer msec */
261 ulonglong lmax_spent_time;/*!< mutex os_wait timer msec */
262 - const char* cmutex_name; /*!< mutex name */
263 ulint mutex_type; /*!< 0=usual mutex, 1=rw_lock mutex */
264 #endif /* UNIV_DEBUG */
265 + const char* cmutex_name; /*!< mutex name */
266 #ifdef UNIV_PFS_MUTEX
267 struct PSI_mutex* pfs_psi; /*!< The performance schema
268 instrumentation hook */
269 --- a/storage/innobase/include/sync0sync.ic
270 +++ b/storage/innobase/include/sync0sync.ic
271 @@ -320,13 +320,13 @@
272 mysql_pfs_key_t key, /*!< in: Performance Schema key */
273 mutex_t* mutex, /*!< in: pointer to memory */
275 - const char* cmutex_name, /*!< in: mutex name */
276 # ifdef UNIV_SYNC_DEBUG
277 ulint level, /*!< in: level */
278 # endif /* UNIV_SYNC_DEBUG */
279 -# endif /* UNIV_DEBUG */
280 const char* cfile_name, /*!< in: file name where created */
281 - ulint cline) /*!< in: file line where created */
282 + ulint cline, /*!< in: file line where created */
283 +# endif /* UNIV_DEBUG */
284 + const char* cmutex_name) /*!< in: mutex name */
286 mutex->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key))
287 ? PSI_server->init_mutex(key, mutex)
288 @@ -334,13 +334,13 @@
290 mutex_create_func(mutex,
293 # ifdef UNIV_SYNC_DEBUG
295 # endif /* UNIV_SYNC_DEBUG */
296 -# endif /* UNIV_DEBUG */
300 +# endif /* UNIV_DEBUG */
303 /******************************************************************//**
304 NOTE! Please use the corresponding macro mutex_free(), not directly
305 --- a/storage/innobase/sync/sync0arr.c
306 +++ b/storage/innobase/sync/sync0arr.c
307 @@ -489,13 +489,12 @@
308 mutex = cell->old_wait_mutex;
311 - "Mutex at %p created file %s line %lu, lock var %lu\n"
312 + "Mutex at %p '%s', lock var %lu\n"
313 #ifdef UNIV_SYNC_DEBUG
314 "Last time reserved in file %s line %lu, "
315 #endif /* UNIV_SYNC_DEBUG */
316 "waiters flag %lu\n",
317 - (void*) mutex, innobase_basename(mutex->cfile_name),
318 - (ulong) mutex->cline,
319 + (void*) mutex, mutex->cmutex_name,
320 (ulong) mutex->lock_word,
321 #ifdef UNIV_SYNC_DEBUG
322 mutex->file_name, (ulong) mutex->line,
324 rwlock = cell->old_wait_rw_lock;
327 - " RW-latch at %p created in file %s line %lu\n",
328 - (void*) rwlock, innobase_basename(rwlock->cfile_name),
329 - (ulong) rwlock->cline);
330 + " RW-latch at %p '%s'\n",
331 + (void*) rwlock, rwlock->lock_name);
332 writer = rw_lock_get_writer(rwlock);
333 if (writer != RW_LOCK_NOT_LOCKED) {
335 --- a/storage/innobase/sync/sync0rw.c
336 +++ b/storage/innobase/sync/sync0rw.c
337 @@ -242,10 +242,10 @@
338 # ifdef UNIV_SYNC_DEBUG
339 ulint level, /*!< in: level */
340 # endif /* UNIV_SYNC_DEBUG */
341 - const char* cmutex_name, /*!< in: mutex name */
342 -#endif /* UNIV_DEBUG */
343 const char* cfile_name, /*!< in: file name where created */
344 - ulint cline) /*!< in: file line where created */
345 + ulint cline, /*!< in: file line where created */
346 +#endif /* UNIV_DEBUG */
347 + const char* cmutex_name) /*!< in: mutex name */
349 /* If this is the very first time a synchronization object is
350 created, then the following call initializes the sync system. */
351 @@ -254,14 +254,15 @@
352 mutex_create(rw_lock_mutex_key, rw_lock_get_mutex(lock),
353 SYNC_NO_ORDER_CHECK);
355 - lock->mutex.cfile_name = cfile_name;
356 - lock->mutex.cline = cline;
357 + ut_d(lock->mutex.cfile_name = cfile_name);
358 + ut_d(lock->mutex.cline = cline);
360 - ut_d(lock->mutex.cmutex_name = cmutex_name);
361 + lock->mutex.cmutex_name = cmutex_name;
362 ut_d(lock->mutex.mutex_type = 1);
363 #else /* INNODB_RW_LOCKS_USE_ATOMICS */
365 - UT_NOT_USED(cmutex_name);
366 + UT_NOT_USED(cfile_name);
367 + UT_NOT_USED(cline);
369 #endif /* INNODB_RW_LOCKS_USE_ATOMICS */
373 ut_d(lock->magic_n = RW_LOCK_MAGIC_N);
375 - lock->cfile_name = cfile_name;
376 - lock->cline = (unsigned int) cline;
377 + lock->lock_name = cmutex_name;
379 lock->count_os_wait = 0;
380 lock->last_s_file_name = "not yet reserved";
381 @@ -405,11 +405,10 @@
382 if (srv_print_latch_waits) {
384 "Thread %lu spin wait rw-s-lock at %p"
385 - " cfile %s cline %lu rnds %lu\n",
386 + " '%s' rnds %lu\n",
387 (ulong) os_thread_pf(os_thread_get_curr_id()),
389 - innobase_basename(lock->cfile_name),
390 - (ulong) lock->cline, (ulong) i);
391 + lock->lock_name, (ulong) i);
394 /* We try once again to obtain the lock */
396 if (srv_print_latch_waits) {
398 "Thread %lu OS wait rw-s-lock at %p"
399 - " cfile %s cline %lu\n",
401 os_thread_pf(os_thread_get_curr_id()),
403 - innobase_basename(lock->cfile_name),
404 - (ulong) lock->cline);
405 + (void*) lock, lock->lock_name);
408 /* these stats may not be accurate */
410 if (srv_print_latch_waits) {
412 "Thread %lu spin wait rw-x-lock at %p"
413 - " cfile %s cline %lu rnds %lu\n",
414 + " '%s' rnds %lu\n",
415 os_thread_pf(os_thread_get_curr_id()), (void*) lock,
416 - innobase_basename(lock->cfile_name),
417 - (ulong) lock->cline, (ulong) i);
418 + lock->lock_name, (ulong) i);
421 sync_array_reserve_cell(sync_primary_wait_array,
423 if (srv_print_latch_waits) {
425 "Thread %lu OS wait for rw-x-lock at %p"
426 - " cfile %s cline %lu\n",
428 os_thread_pf(os_thread_get_curr_id()), (void*) lock,
429 - innobase_basename(lock->cfile_name),
430 - (ulong) lock->cline);
434 /* these stats may not be accurate */
435 --- a/storage/innobase/sync/sync0sync.c
436 +++ b/storage/innobase/sync/sync0sync.c
437 @@ -270,13 +270,13 @@
439 mutex_t* mutex, /*!< in: pointer to memory */
441 - const char* cmutex_name, /*!< in: mutex name */
442 # ifdef UNIV_SYNC_DEBUG
443 ulint level, /*!< in: level */
444 # endif /* UNIV_SYNC_DEBUG */
445 -#endif /* UNIV_DEBUG */
446 const char* cfile_name, /*!< in: file name where created */
447 - ulint cline) /*!< in: file line where created */
448 + ulint cline, /*!< in: file line where created */
449 +#endif /* UNIV_DEBUG */
450 + const char* cmutex_name) /*!< in: mutex name */
452 #if defined(HAVE_ATOMIC_BUILTINS)
453 mutex_reset_lock_word(mutex);
454 @@ -294,11 +294,13 @@
455 mutex->file_name = "not yet reserved";
456 mutex->level = level;
457 #endif /* UNIV_SYNC_DEBUG */
459 mutex->cfile_name = cfile_name;
460 mutex->cline = cline;
461 +#endif /* UNIV_DEBUG */
462 mutex->count_os_wait = 0;
464 mutex->cmutex_name= cmutex_name;
466 mutex->count_using= 0;
467 mutex->mutex_type= 0;
468 mutex->lspent_time= 0;
470 #ifdef UNIV_SRV_PRINT_LATCH_WAITS
472 "Thread %lu spin wait mutex at %p"
473 - " cfile %s cline %lu rnds %lu\n",
474 + " '%s' rnds %lu\n",
475 (ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex,
476 - innobase_basename(mutex->cfile_name),
477 - (ulong) mutex->cline, (ulong) i);
478 + mutex->cmutex_name, (ulong) i);
481 mutex_spin_round_count += i;
484 #ifdef UNIV_SRV_PRINT_LATCH_WAITS
486 - "Thread %lu OS wait mutex at %p cfile %s cline %lu rnds %lu\n",
487 + "Thread %lu OS wait mutex at %p '%s' rnds %lu\n",
488 (ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex,
489 - innobase_basename(mutex->cfile_name),
490 - (ulong) mutex->cline, (ulong) i);
491 + mutex->cmutex_name, (ulong) i);
494 mutex_os_wait_count++;
497 if (mutex->magic_n == MUTEX_MAGIC_N) {
499 - "Mutex created at %s %lu\n",
500 - innobase_basename(mutex->cfile_name),
501 - (ulong) mutex->cline);
503 + mutex->cmutex_name);
505 if (mutex_get_lock_word(mutex) != 0) {