]>
Commit | Line | Data |
---|---|---|
b4e1fa2c AM |
1 | # name : innodb_show_lock_name.patch |
2 | # introduced : 11 or before | |
3 | # maintainer : Yasufumi | |
4 | # | |
5 | #!!! notice !!! | |
6 | # Any small change to this file in the main branch | |
7 | # should be done or reviewed by the maintainer! | |
8 | diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc | |
9 | --- a/storage/innobase/handler/ha_innodb.cc 2010-12-03 17:34:35.285040381 +0900 | |
10 | +++ b/storage/innobase/handler/ha_innodb.cc 2010-12-03 17:35:12.974975252 +0900 | |
11 | @@ -9491,8 +9491,8 @@ | |
12 | rw_lock_wait_time += mutex->lspent_time; | |
13 | } | |
14 | #else /* UNIV_DEBUG */ | |
15 | - buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s:%lu", | |
16 | - mutex->cfile_name, (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); | |
21 | ||
22 | @@ -9507,9 +9507,8 @@ | |
23 | ||
24 | if (block_mutex) { | |
25 | buf1len = (uint) my_snprintf(buf1, sizeof buf1, | |
26 | - "combined %s:%lu", | |
27 | - block_mutex->cfile_name, | |
28 | - (ulong) block_mutex->cline); | |
29 | + "combined %s", | |
30 | + block_mutex->cmutex_name); | |
31 | buf2len = (uint) my_snprintf(buf2, sizeof buf2, | |
32 | "os_waits=%lu", | |
33 | (ulong) block_mutex_oswait_count); | |
34 | @@ -9538,8 +9537,8 @@ | |
35 | continue; | |
36 | } | |
37 | ||
38 | - buf1len = my_snprintf(buf1, sizeof buf1, "%s:%lu", | |
39 | - lock->cfile_name, (ulong) lock->cline); | |
40 | + buf1len = my_snprintf(buf1, sizeof buf1, "%s", | |
41 | + lock->lock_name); | |
42 | buf2len = my_snprintf(buf2, sizeof buf2, "os_waits=%lu", | |
43 | (ulong) lock->count_os_wait); | |
44 | ||
45 | @@ -9553,9 +9552,8 @@ | |
46 | ||
47 | if (block_lock) { | |
48 | buf1len = (uint) my_snprintf(buf1, sizeof buf1, | |
49 | - "combined %s:%lu", | |
50 | - block_lock->cfile_name, | |
51 | - (ulong) block_lock->cline); | |
52 | + "combined %s", | |
53 | + block_lock->lock_name); | |
54 | buf2len = (uint) my_snprintf(buf2, sizeof buf2, | |
55 | "os_waits=%lu", | |
56 | (ulong) block_lock_oswait_count); | |
57 | diff -ruN a/storage/innobase/include/sync0rw.h b/storage/innobase/include/sync0rw.h | |
58 | --- a/storage/innobase/include/sync0rw.h 2010-12-03 15:49:59.225953164 +0900 | |
59 | +++ b/storage/innobase/include/sync0rw.h 2010-12-03 17:35:12.978024458 +0900 | |
60 | @@ -144,7 +144,7 @@ | |
61 | # endif/* UNIV_SYNC_DEBUG */ | |
62 | # else /* UNIV_DEBUG */ | |
63 | # define rw_lock_create(K, L, level) \ | |
64 | - rw_lock_create_func((L), __FILE__, __LINE__) | |
65 | + rw_lock_create_func((L), #L, NULL, 0) | |
66 | # endif /* UNIV_DEBUG */ | |
67 | ||
68 | /**************************************************************//** | |
69 | @@ -197,7 +197,7 @@ | |
70 | # endif/* UNIV_SYNC_DEBUG */ | |
71 | # else /* UNIV_DEBUG */ | |
72 | # define rw_lock_create(K, L, level) \ | |
73 | - pfs_rw_lock_create_func((K), (L), __FILE__, __LINE__) | |
74 | + pfs_rw_lock_create_func((K), (L), #L, NULL, 0) | |
75 | # endif /* UNIV_DEBUG */ | |
76 | ||
77 | /****************************************************************** | |
78 | @@ -255,8 +255,8 @@ | |
79 | # ifdef UNIV_SYNC_DEBUG | |
80 | ulint level, /*!< in: level */ | |
81 | # endif /* UNIV_SYNC_DEBUG */ | |
82 | - const char* cmutex_name, /*!< in: mutex name */ | |
83 | #endif /* UNIV_DEBUG */ | |
84 | + const char* cmutex_name, /*!< in: mutex name */ | |
85 | const char* cfile_name, /*!< in: file name where created */ | |
86 | ulint cline); /*!< in: file line where created */ | |
87 | /******************************************************************//** | |
88 | @@ -609,7 +609,8 @@ | |
89 | struct PSI_rwlock *pfs_psi;/*!< The instrumentation hook */ | |
90 | #endif | |
91 | ulint count_os_wait; /*!< Count of os_waits. May not be accurate */ | |
92 | - const char* cfile_name;/*!< File name where lock created */ | |
93 | + //const char* cfile_name;/*!< File name where lock created */ | |
94 | + const char* lock_name;/*!< lock name */ | |
95 | /* last s-lock file/line is not guaranteed to be correct */ | |
96 | const char* last_s_file_name;/*!< File name where last s-locked */ | |
97 | const char* last_x_file_name;/*!< File name where last x-locked */ | |
98 | @@ -620,7 +621,7 @@ | |
99 | are at the start of this struct, thus we can | |
100 | peek this field without causing much memory | |
101 | bus traffic */ | |
102 | - unsigned cline:14; /*!< Line where created */ | |
103 | + //unsigned cline:14; /*!< Line where created */ | |
104 | unsigned last_s_line:14; /*!< Line number where last time s-locked */ | |
105 | unsigned last_x_line:14; /*!< Line number where last time x-locked */ | |
106 | #ifdef UNIV_DEBUG | |
107 | @@ -690,8 +691,8 @@ | |
108 | # ifdef UNIV_SYNC_DEBUG | |
109 | ulint level, /*!< in: level */ | |
110 | # endif /* UNIV_SYNC_DEBUG */ | |
111 | - const char* cmutex_name, /*!< in: mutex name */ | |
112 | #endif /* UNIV_DEBUG */ | |
113 | + const char* cmutex_name, /*!< in: mutex name */ | |
114 | const char* cfile_name, /*!< in: file name where created */ | |
115 | ulint cline); /*!< in: file line where created */ | |
116 | ||
117 | diff -ruN a/storage/innobase/include/sync0rw.ic b/storage/innobase/include/sync0rw.ic | |
118 | --- a/storage/innobase/include/sync0rw.ic 2010-11-03 07:01:13.000000000 +0900 | |
119 | +++ b/storage/innobase/include/sync0rw.ic 2010-12-03 17:35:12.980024605 +0900 | |
120 | @@ -640,8 +640,8 @@ | |
121 | # ifdef UNIV_SYNC_DEBUG | |
122 | ulint level, /*!< in: level */ | |
123 | # endif /* UNIV_SYNC_DEBUG */ | |
124 | - const char* cmutex_name, /*!< in: mutex name */ | |
125 | # endif /* UNIV_DEBUG */ | |
126 | + const char* cmutex_name, /*!< in: mutex name */ | |
127 | const char* cfile_name, /*!< in: file name where created */ | |
128 | ulint cline) /*!< in: file line where created */ | |
129 | { | |
130 | @@ -656,8 +656,8 @@ | |
131 | # ifdef UNIV_SYNC_DEBUG | |
132 | level, | |
133 | # endif /* UNIV_SYNC_DEBUG */ | |
134 | - cmutex_name, | |
135 | # endif /* UNIV_DEBUG */ | |
136 | + cmutex_name, | |
137 | cfile_name, | |
138 | cline); | |
139 | } | |
140 | diff -ruN a/storage/innobase/include/sync0sync.h b/storage/innobase/include/sync0sync.h | |
141 | --- a/storage/innobase/include/sync0sync.h 2010-12-03 15:49:59.227955503 +0900 | |
142 | +++ b/storage/innobase/include/sync0sync.h 2010-12-03 17:35:12.982023946 +0900 | |
143 | @@ -166,7 +166,7 @@ | |
144 | # endif/* UNIV_SYNC_DEBUG */ | |
145 | # else | |
146 | # define mutex_create(K, M, level) \ | |
147 | - pfs_mutex_create_func((K), (M), __FILE__, __LINE__) | |
148 | + pfs_mutex_create_func((K), (M), #M, NULL, 0) | |
149 | # endif /* UNIV_DEBUG */ | |
150 | ||
151 | # define mutex_enter(M) \ | |
152 | @@ -193,7 +193,7 @@ | |
153 | # endif /* UNIV_SYNC_DEBUG */ | |
154 | # else /* UNIV_DEBUG */ | |
155 | # define mutex_create(K, M, level) \ | |
156 | - mutex_create_func((M), __FILE__, __LINE__) | |
157 | + mutex_create_func((M), #M, NULL, 0) | |
158 | # endif /* UNIV_DEBUG */ | |
159 | ||
160 | # define mutex_enter(M) mutex_enter_func((M), __FILE__, __LINE__) | |
161 | @@ -217,8 +217,8 @@ | |
162 | mutex_create_func( | |
163 | /*==============*/ | |
164 | mutex_t* mutex, /*!< in: pointer to memory */ | |
165 | -#ifdef UNIV_DEBUG | |
166 | const char* cmutex_name, /*!< in: mutex name */ | |
167 | +#ifdef UNIV_DEBUG | |
168 | # ifdef UNIV_SYNC_DEBUG | |
169 | ulint level, /*!< in: level */ | |
170 | # endif /* UNIV_SYNC_DEBUG */ | |
171 | @@ -291,8 +291,8 @@ | |
172 | /*==================*/ | |
173 | PSI_mutex_key key, /*!< in: Performance Schema key */ | |
174 | mutex_t* mutex, /*!< in: pointer to memory */ | |
175 | -# ifdef UNIV_DEBUG | |
176 | const char* cmutex_name, /*!< in: mutex name */ | |
177 | +# ifdef UNIV_DEBUG | |
178 | # ifdef UNIV_SYNC_DEBUG | |
179 | ulint level, /*!< in: level */ | |
180 | # endif /* UNIV_SYNC_DEBUG */ | |
181 | @@ -723,9 +723,9 @@ | |
182 | ulint line; /*!< Line where the mutex was locked */ | |
183 | ulint level; /*!< Level in the global latching order */ | |
184 | #endif /* UNIV_SYNC_DEBUG */ | |
185 | +#ifdef UNIV_DEBUG | |
186 | const char* cfile_name;/*!< File name where mutex created */ | |
187 | ulint cline; /*!< Line where created */ | |
188 | -#ifdef UNIV_DEBUG | |
189 | os_thread_id_t thread_id; /*!< The thread id of the thread | |
190 | which locked the mutex. */ | |
191 | ulint magic_n; /*!< MUTEX_MAGIC_N */ | |
192 | @@ -740,9 +740,9 @@ | |
193 | ulong count_os_yield; /*!< count of os_wait */ | |
194 | ulonglong lspent_time; /*!< mutex os_wait timer msec */ | |
195 | ulonglong lmax_spent_time;/*!< mutex os_wait timer msec */ | |
196 | - const char* cmutex_name; /*!< mutex name */ | |
197 | ulint mutex_type; /*!< 0=usual mutex, 1=rw_lock mutex */ | |
198 | #endif /* UNIV_DEBUG */ | |
199 | + const char* cmutex_name; /*!< mutex name */ | |
200 | #ifdef UNIV_PFS_MUTEX | |
201 | struct PSI_mutex* pfs_psi; /*!< The performance schema | |
202 | instrumentation hook */ | |
203 | diff -ruN a/storage/innobase/include/sync0sync.ic b/storage/innobase/include/sync0sync.ic | |
204 | --- a/storage/innobase/include/sync0sync.ic 2010-11-03 07:01:13.000000000 +0900 | |
205 | +++ b/storage/innobase/include/sync0sync.ic 2010-12-03 17:35:12.984024599 +0900 | |
206 | @@ -320,8 +320,8 @@ | |
207 | /*==================*/ | |
208 | mysql_pfs_key_t key, /*!< in: Performance Schema key */ | |
209 | mutex_t* mutex, /*!< in: pointer to memory */ | |
210 | -# ifdef UNIV_DEBUG | |
211 | const char* cmutex_name, /*!< in: mutex name */ | |
212 | +# ifdef UNIV_DEBUG | |
213 | # ifdef UNIV_SYNC_DEBUG | |
214 | ulint level, /*!< in: level */ | |
215 | # endif /* UNIV_SYNC_DEBUG */ | |
216 | @@ -334,8 +334,8 @@ | |
217 | : NULL; | |
218 | ||
219 | mutex_create_func(mutex, | |
220 | -# ifdef UNIV_DEBUG | |
221 | cmutex_name, | |
222 | +# ifdef UNIV_DEBUG | |
223 | # ifdef UNIV_SYNC_DEBUG | |
224 | level, | |
225 | # endif /* UNIV_SYNC_DEBUG */ | |
226 | diff -ruN a/storage/innobase/sync/sync0arr.c b/storage/innobase/sync/sync0arr.c | |
227 | --- a/storage/innobase/sync/sync0arr.c 2010-12-03 15:09:51.304953409 +0900 | |
228 | +++ b/storage/innobase/sync/sync0arr.c 2010-12-03 17:35:12.985024561 +0900 | |
229 | @@ -488,12 +488,12 @@ | |
230 | mutex = cell->old_wait_mutex; | |
231 | ||
232 | fprintf(file, | |
233 | - "Mutex at %p created file %s line %lu, lock var %lu\n" | |
234 | + "Mutex at %p '%s', lock var %lu\n" | |
235 | #ifdef UNIV_SYNC_DEBUG | |
236 | "Last time reserved in file %s line %lu, " | |
237 | #endif /* UNIV_SYNC_DEBUG */ | |
238 | "waiters flag %lu\n", | |
239 | - (void*) mutex, mutex->cfile_name, (ulong) mutex->cline, | |
240 | + (void*) mutex, mutex->cmutex_name, | |
241 | (ulong) mutex->lock_word, | |
242 | #ifdef UNIV_SYNC_DEBUG | |
243 | mutex->file_name, (ulong) mutex->line, | |
244 | @@ -511,9 +511,8 @@ | |
245 | rwlock = cell->old_wait_rw_lock; | |
246 | ||
247 | fprintf(file, | |
248 | - " RW-latch at %p created in file %s line %lu\n", | |
249 | - (void*) rwlock, rwlock->cfile_name, | |
250 | - (ulong) rwlock->cline); | |
251 | + " RW-latch at %p '%s'\n", | |
252 | + (void*) rwlock, rwlock->lock_name); | |
253 | writer = rw_lock_get_writer(rwlock); | |
254 | if (writer != RW_LOCK_NOT_LOCKED) { | |
255 | fprintf(file, | |
256 | diff -ruN a/storage/innobase/sync/sync0rw.c b/storage/innobase/sync/sync0rw.c | |
257 | --- a/storage/innobase/sync/sync0rw.c 2010-11-03 07:01:13.000000000 +0900 | |
258 | +++ b/storage/innobase/sync/sync0rw.c 2010-12-03 17:35:12.987029059 +0900 | |
259 | @@ -241,8 +241,8 @@ | |
260 | # ifdef UNIV_SYNC_DEBUG | |
261 | ulint level, /*!< in: level */ | |
262 | # endif /* UNIV_SYNC_DEBUG */ | |
263 | - const char* cmutex_name, /*!< in: mutex name */ | |
264 | #endif /* UNIV_DEBUG */ | |
265 | + const char* cmutex_name, /*!< in: mutex name */ | |
266 | const char* cfile_name, /*!< in: file name where created */ | |
267 | ulint cline) /*!< in: file line where created */ | |
268 | { | |
269 | @@ -253,14 +253,15 @@ | |
270 | mutex_create(rw_lock_mutex_key, rw_lock_get_mutex(lock), | |
271 | SYNC_NO_ORDER_CHECK); | |
272 | ||
273 | - lock->mutex.cfile_name = cfile_name; | |
274 | - lock->mutex.cline = cline; | |
275 | + ut_d(lock->mutex.cfile_name = cfile_name); | |
276 | + ut_d(lock->mutex.cline = cline); | |
277 | ||
278 | - ut_d(lock->mutex.cmutex_name = cmutex_name); | |
279 | + lock->mutex.cmutex_name = cmutex_name; | |
280 | ut_d(lock->mutex.mutex_type = 1); | |
281 | #else /* INNODB_RW_LOCKS_USE_ATOMICS */ | |
282 | # ifdef UNIV_DEBUG | |
283 | - UT_NOT_USED(cmutex_name); | |
284 | + UT_NOT_USED(cfile_name); | |
285 | + UT_NOT_USED(cline); | |
286 | # endif | |
287 | #endif /* INNODB_RW_LOCKS_USE_ATOMICS */ | |
288 | ||
289 | @@ -280,8 +281,7 @@ | |
290 | ||
291 | ut_d(lock->magic_n = RW_LOCK_MAGIC_N); | |
292 | ||
293 | - lock->cfile_name = cfile_name; | |
294 | - lock->cline = (unsigned int) cline; | |
295 | + lock->lock_name = cmutex_name; | |
296 | ||
297 | lock->count_os_wait = 0; | |
298 | lock->last_s_file_name = "not yet reserved"; | |
299 | @@ -401,10 +401,10 @@ | |
300 | if (srv_print_latch_waits) { | |
301 | fprintf(stderr, | |
302 | "Thread %lu spin wait rw-s-lock at %p" | |
303 | - " cfile %s cline %lu rnds %lu\n", | |
304 | + " '%s' rnds %lu\n", | |
305 | (ulong) os_thread_pf(os_thread_get_curr_id()), | |
306 | (void*) lock, | |
307 | - lock->cfile_name, (ulong) lock->cline, (ulong) i); | |
308 | + lock->lock_name, (ulong) i); | |
309 | } | |
310 | ||
311 | /* We try once again to obtain the lock */ | |
312 | @@ -437,10 +437,9 @@ | |
313 | if (srv_print_latch_waits) { | |
314 | fprintf(stderr, | |
315 | "Thread %lu OS wait rw-s-lock at %p" | |
316 | - " cfile %s cline %lu\n", | |
317 | + " '%s'\n", | |
318 | os_thread_pf(os_thread_get_curr_id()), | |
319 | - (void*) lock, lock->cfile_name, | |
320 | - (ulong) lock->cline); | |
321 | + (void*) lock, lock->lock_name); | |
322 | } | |
323 | ||
324 | /* these stats may not be accurate */ | |
325 | @@ -659,9 +658,9 @@ | |
326 | if (srv_print_latch_waits) { | |
327 | fprintf(stderr, | |
328 | "Thread %lu spin wait rw-x-lock at %p" | |
329 | - " cfile %s cline %lu rnds %lu\n", | |
330 | + " '%s' rnds %lu\n", | |
331 | os_thread_pf(os_thread_get_curr_id()), (void*) lock, | |
332 | - lock->cfile_name, (ulong) lock->cline, (ulong) i); | |
333 | + lock->lock_name, (ulong) i); | |
334 | } | |
335 | ||
336 | sync_array_reserve_cell(sync_primary_wait_array, | |
337 | @@ -682,9 +681,9 @@ | |
338 | if (srv_print_latch_waits) { | |
339 | fprintf(stderr, | |
340 | "Thread %lu OS wait for rw-x-lock at %p" | |
341 | - " cfile %s cline %lu\n", | |
342 | + " '%s'\n", | |
343 | os_thread_pf(os_thread_get_curr_id()), (void*) lock, | |
344 | - lock->cfile_name, (ulong) lock->cline); | |
345 | + lock->lock_name); | |
346 | } | |
347 | ||
348 | /* these stats may not be accurate */ | |
349 | diff -ruN a/storage/innobase/sync/sync0sync.c b/storage/innobase/sync/sync0sync.c | |
350 | --- a/storage/innobase/sync/sync0sync.c 2010-12-03 15:49:59.233955565 +0900 | |
351 | +++ b/storage/innobase/sync/sync0sync.c 2010-12-03 17:35:12.989024400 +0900 | |
352 | @@ -249,8 +249,8 @@ | |
353 | mutex_create_func( | |
354 | /*==============*/ | |
355 | mutex_t* mutex, /*!< in: pointer to memory */ | |
356 | -#ifdef UNIV_DEBUG | |
357 | const char* cmutex_name, /*!< in: mutex name */ | |
358 | +#ifdef UNIV_DEBUG | |
359 | # ifdef UNIV_SYNC_DEBUG | |
360 | ulint level, /*!< in: level */ | |
361 | # endif /* UNIV_SYNC_DEBUG */ | |
362 | @@ -274,11 +274,13 @@ | |
363 | mutex->file_name = "not yet reserved"; | |
364 | mutex->level = level; | |
365 | #endif /* UNIV_SYNC_DEBUG */ | |
366 | +#ifdef UNIV_DEBUG | |
367 | mutex->cfile_name = cfile_name; | |
368 | mutex->cline = cline; | |
369 | +#endif /* UNIV_DEBUG */ | |
370 | mutex->count_os_wait = 0; | |
371 | -#ifdef UNIV_DEBUG | |
372 | mutex->cmutex_name= cmutex_name; | |
373 | +#ifdef UNIV_DEBUG | |
374 | mutex->count_using= 0; | |
375 | mutex->mutex_type= 0; | |
376 | mutex->lspent_time= 0; | |
377 | @@ -532,9 +534,9 @@ | |
378 | #ifdef UNIV_SRV_PRINT_LATCH_WAITS | |
379 | fprintf(stderr, | |
380 | "Thread %lu spin wait mutex at %p" | |
381 | - " cfile %s cline %lu rnds %lu\n", | |
382 | + " '%s' rnds %lu\n", | |
383 | (ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex, | |
384 | - mutex->cfile_name, (ulong) mutex->cline, (ulong) i); | |
385 | + mutex->cmutex_name, (ulong) i); | |
386 | #endif | |
387 | ||
388 | mutex_spin_round_count += i; | |
389 | @@ -609,9 +611,9 @@ | |
390 | ||
391 | #ifdef UNIV_SRV_PRINT_LATCH_WAITS | |
392 | fprintf(stderr, | |
393 | - "Thread %lu OS wait mutex at %p cfile %s cline %lu rnds %lu\n", | |
394 | + "Thread %lu OS wait mutex at %p '%s' rnds %lu\n", | |
395 | (ulong) os_thread_pf(os_thread_get_curr_id()), (void*) mutex, | |
396 | - mutex->cfile_name, (ulong) mutex->cline, (ulong) i); | |
397 | + mutex->cmutex_name, (ulong) i); | |
398 | #endif | |
399 | ||
400 | mutex_os_wait_count++; | |
401 | @@ -913,9 +915,8 @@ | |
402 | ||
403 | if (mutex->magic_n == MUTEX_MAGIC_N) { | |
404 | fprintf(stderr, | |
405 | - "Mutex created at %s %lu\n", | |
406 | - mutex->cfile_name, | |
407 | - (ulong) mutex->cline); | |
408 | + "Mutex '%s'\n", | |
409 | + mutex->cmutex_name); | |
410 | ||
411 | if (mutex_get_lock_word(mutex) != 0) { | |
412 | const char* file_name; |