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
|
diff -r e9fb5b8bcf78 innobase/include/srv0srv.h
--- a/innobase/include/srv0srv.h Mon Jun 01 00:36:33 2009 -0700
+++ b/innobase/include/srv0srv.h Mon Jun 01 00:36:41 2009 -0700
@@ -80,6 +80,8 @@
extern ulint srv_log_file_size;
extern ulint srv_log_buffer_size;
extern ulong srv_flush_log_at_trx_commit;
+extern ulong srv_show_locks_held;
+extern ulong srv_show_verbose_locks;
extern byte srv_latin1_ordering[256];/* The sort order table of the latin1
character set */
diff -r e9fb5b8bcf78 innobase/lock/lock0lock.c
--- a/innobase/lock/lock0lock.c Mon Jun 01 00:36:33 2009 -0700
+++ b/innobase/lock/lock0lock.c Mon Jun 01 00:36:41 2009 -0700
@@ -4181,6 +4181,7 @@
#endif /* UNIV_SYNC_DEBUG */
}
+ if ( srv_show_verbose_locks ) {
for (i = 0; i < lock_rec_get_n_bits(lock); i++) {
if (lock_rec_get_nth_bit(lock, i)) {
@@ -4198,6 +4199,7 @@
putc('\n', file);
}
}
+ } /* srv_show_verbose_locks */
mtr_commit(&mtr);
if (UNIV_LIKELY_NULL(heap)) {
@@ -4369,7 +4371,7 @@
}
}
- if (!srv_print_innodb_lock_monitor) {
+ if (!srv_print_innodb_lock_monitor && !srv_show_locks_held) {
nth_trx++;
goto loop;
}
@@ -4426,9 +4428,9 @@
nth_lock++;
- if (nth_lock >= 10) {
+ if (nth_lock >= srv_show_locks_held) {
fputs(
- "10 LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
+ "TOO MANY LOCKS PRINTED FOR THIS TRX: SUPPRESSING FURTHER PRINTS\n",
file);
nth_trx++;
diff -r e9fb5b8bcf78 innobase/srv/srv0srv.c
--- a/innobase/srv/srv0srv.c Mon Jun 01 00:36:33 2009 -0700
+++ b/innobase/srv/srv0srv.c Mon Jun 01 00:36:41 2009 -0700
@@ -116,6 +116,8 @@
ulint srv_log_file_size = ULINT_MAX; /* size in database pages */
ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */
ulong srv_flush_log_at_trx_commit = 1;
+ulint srv_show_locks_held = 10;
+ulint srv_show_verbose_locks = 0;
byte srv_latin1_ordering[256] /* The sort order table of the latin1
character set. The following table is
@@ -1711,24 +1713,6 @@
mutex_exit(&dict_foreign_err_mutex);
- lock_print_info_summary(file);
- if (trx_start) {
- long t = ftell(file);
- if (t < 0) {
- *trx_start = ULINT_UNDEFINED;
- } else {
- *trx_start = (ulint) t;
- }
- }
- lock_print_info_all_transactions(file);
- if (trx_end) {
- long t = ftell(file);
- if (t < 0) {
- *trx_end = ULINT_UNDEFINED;
- } else {
- *trx_end = (ulint) t;
- }
- }
fputs("--------\n"
"FILE I/O\n"
"--------\n", file);
@@ -1822,6 +1806,25 @@
srv_n_rows_deleted_old = srv_n_rows_deleted;
srv_n_rows_read_old = srv_n_rows_read;
+ lock_print_info_summary(file);
+ if (trx_start) {
+ long t = ftell(file);
+ if (t < 0) {
+ *trx_start = ULINT_UNDEFINED;
+ } else {
+ *trx_start = (ulint) t;
+ }
+ }
+ lock_print_info_all_transactions(file);
+ if (trx_end) {
+ long t = ftell(file);
+ if (t < 0) {
+ *trx_end = ULINT_UNDEFINED;
+ } else {
+ *trx_end = (ulint) t;
+ }
+ }
+
fputs("----------------------------\n"
"END OF INNODB MONITOR OUTPUT\n"
"============================\n", file);
diff -r e9fb5b8bcf78 libmysqld/set_var.cc
--- a/libmysqld/set_var.cc Mon Jun 01 00:36:33 2009 -0700
+++ b/libmysqld/set_var.cc Mon Jun 01 00:36:41 2009 -0700
@@ -825,6 +825,8 @@
&sys_innodb_thread_concurrency,
&sys_innodb_commit_concurrency,
&sys_innodb_flush_log_at_trx_commit,
+ &sys_innodb_show_locks_held,
+ &sys_innodb_show_verbose_locks,
#endif
&sys_trust_routine_creators,
&sys_trust_function_creators,
@@ -942,6 +944,8 @@
{"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
{"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
{sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
{"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
{"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
{"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
diff -r e9fb5b8bcf78 patch_info/innodb_locks_held.info
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/patch_info/innodb_locks_held.info Mon Jun 01 00:36:41 2009 -0700
@@ -0,0 +1,6 @@
+File=innodb_locks_held.patch
+Name=Add locks held, remove locked records in SHOW INNODB STATUS
+Version=1.0
+Author=Baron Schwartz <baron@xaprb.com>
+License=GPL
+Comment=Bug #29126 fix
diff -r e9fb5b8bcf78 sql/ha_innodb.h
--- a/sql/ha_innodb.h Mon Jun 01 00:36:33 2009 -0700
+++ b/sql/ha_innodb.h Mon Jun 01 00:36:41 2009 -0700
@@ -243,6 +243,8 @@
extern ulong srv_enable_unsafe_group_commit;
extern uint srv_read_ahead;
extern uint srv_adaptive_checkpoint;
+extern ulong srv_show_locks_held;
+extern ulong srv_show_verbose_locks;
/* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does
NOT update cardinality for indexes of InnoDB table". By default we are
diff -r e9fb5b8bcf78 sql/mysqld.cc
--- a/sql/mysqld.cc Mon Jun 01 00:36:33 2009 -0700
+++ b/sql/mysqld.cc Mon Jun 01 00:36:41 2009 -0700
@@ -5016,6 +5016,8 @@
OPT_INNODB_MAX_PURGE_LAG,
OPT_INNODB_FILE_IO_THREADS,
OPT_INNODB_LOCK_WAIT_TIMEOUT,
+ OPT_INNODB_SHOW_LOCKS_HELD,
+ OPT_INNODB_SHOW_VERBOSE_LOCKS,
OPT_INNODB_THREAD_CONCURRENCY,
OPT_INNODB_COMMIT_CONCURRENCY,
OPT_INNODB_FORCE_RECOVERY,
@@ -5364,6 +5366,14 @@
(gptr*) &srv_flush_log_at_trx_commit,
(gptr*) &srv_flush_log_at_trx_commit,
0, GET_ULONG, OPT_ARG, 1, 0, 2, 0, 0, 0},
+ {"innodb_show_locks_held", OPT_INNODB_SHOW_LOCKS_HELD,
+ "Number of locks held to print for each InnoDB transaction in SHOW INNODB STATUS.",
+ (gptr*) &srv_show_locks_held, (gptr*) &srv_show_locks_held,
+ 0, GET_LONG, OPT_ARG, 10, 0, 1000, 0, 1, 0},
+ {"innodb_show_verbose_locks", OPT_INNODB_SHOW_VERBOSE_LOCKS,
+ "Whether to show records locked in SHOW INNODB STATUS.",
+ (gptr*) &srv_show_verbose_locks, (gptr*) &srv_show_verbose_locks,
+ 0, GET_LONG, OPT_ARG, 0, 0, 1, 0, 1, 0},
{"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
"With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
(gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
diff -r e9fb5b8bcf78 sql/set_var.cc
--- a/sql/set_var.cc Mon Jun 01 00:36:33 2009 -0700
+++ b/sql/set_var.cc Mon Jun 01 00:36:41 2009 -0700
@@ -527,6 +527,12 @@
sys_var_enum sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
&srv_adaptive_checkpoint,
&innodb_adaptive_checkpoint_typelib, fix_innodb_adaptive_checkpoint);
+sys_var_long_ptr sys_innodb_show_locks_held(
+ "innodb_show_locks_held",
+ &srv_show_locks_held);
+sys_var_long_ptr sys_innodb_show_verbose_locks(
+ "innodb_show_verbose_locks",
+ &srv_show_verbose_locks);
sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path",
&innobase_data_file_path);
sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir",
@@ -906,6 +912,8 @@
&sys_innodb_read_ahead,
&sys_innodb_enable_unsafe_group_commit,
&sys_innodb_adaptive_checkpoint,
+ &sys_innodb_show_locks_held,
+ &sys_innodb_show_verbose_locks,
#endif
&sys_trust_routine_creators,
&sys_trust_function_creators,
@@ -1023,6 +1031,8 @@
{"innodb_file_io_threads", (char*) &innobase_file_io_threads, SHOW_LONG },
{"innodb_file_per_table", (char*) &innobase_file_per_table, SHOW_MY_BOOL},
{sys_innodb_flush_log_at_trx_commit.name, (char*) &sys_innodb_flush_log_at_trx_commit, SHOW_SYS},
+ {sys_innodb_show_locks_held.name, (char*) &sys_innodb_show_locks_held, SHOW_SYS },
+ {sys_innodb_show_verbose_locks.name, (char*) &sys_innodb_show_verbose_locks, SHOW_SYS },
{"innodb_flush_method", (char*) &innobase_unix_file_flush_method, SHOW_CHAR_PTR},
{"innodb_force_recovery", (char*) &innobase_force_recovery, SHOW_LONG },
{"innodb_lock_wait_timeout", (char*) &innobase_lock_wait_timeout, SHOW_LONG },
|