summaryrefslogtreecommitdiff
blob: a4ae8ab8c935973a2b799deee2b6817c95e170eb (plain)
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 7d3d7786b927 innobase/include/srv0srv.h
--- a/innobase/include/srv0srv.h	Tue Feb 17 22:33:33 2009 -0800
+++ b/innobase/include/srv0srv.h	Tue Feb 17 22:33:47 2009 -0800
@@ -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 7d3d7786b927 innobase/lock/lock0lock.c
--- a/innobase/lock/lock0lock.c	Tue Feb 17 22:33:33 2009 -0800
+++ b/innobase/lock/lock0lock.c	Tue Feb 17 22:33:47 2009 -0800
@@ -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 7d3d7786b927 innobase/srv/srv0srv.c
--- a/innobase/srv/srv0srv.c	Tue Feb 17 22:33:33 2009 -0800
+++ b/innobase/srv/srv0srv.c	Tue Feb 17 22:33:47 2009 -0800
@@ -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
@@ -1703,24 +1705,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);
@@ -1813,6 +1797,25 @@
 	srv_n_rows_updated_old = srv_n_rows_updated;
 	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"
diff -r 7d3d7786b927 libmysqld/set_var.cc
--- a/libmysqld/set_var.cc	Tue Feb 17 22:33:33 2009 -0800
+++ b/libmysqld/set_var.cc	Tue Feb 17 22:33:47 2009 -0800
@@ -821,6 +821,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,
@@ -936,6 +938,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 7d3d7786b927 patch_info/innodb_locks_held.info
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patch_info/innodb_locks_held.info	Tue Feb 17 22:33:47 2009 -0800
@@ -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 7d3d7786b927 sql/ha_innodb.h
--- a/sql/ha_innodb.h	Tue Feb 17 22:33:33 2009 -0800
+++ b/sql/ha_innodb.h	Tue Feb 17 22:33:47 2009 -0800
@@ -242,6 +242,8 @@
 extern ulong srv_flush_neighbor_pages;
 extern uint srv_read_ahead;
 extern ulong srv_adaptive_checkpoint;
+extern ulong srv_show_locks_held;
+extern ulong srv_show_verbose_locks;
 }
 
 bool innobase_init(void);
diff -r 7d3d7786b927 sql/mysqld.cc
--- a/sql/mysqld.cc	Tue Feb 17 22:33:33 2009 -0800
+++ b/sql/mysqld.cc	Tue Feb 17 22:33:47 2009 -0800
@@ -5012,6 +5012,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,
@@ -5356,6 +5358,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 7d3d7786b927 sql/set_var.cc
--- a/sql/set_var.cc	Tue Feb 17 22:33:33 2009 -0800
+++ b/sql/set_var.cc	Tue Feb 17 22:33:47 2009 -0800
@@ -522,6 +522,12 @@
                                       &innodb_read_ahead_typelib, fix_innodb_read_ahead);
 sys_var_long_ptr	sys_innodb_adaptive_checkpoint("innodb_adaptive_checkpoint",
                                                       &srv_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", 
@@ -893,6 +899,8 @@
   &sys_innodb_flush_neighbor_pages,
   &sys_innodb_read_ahead,
   &sys_innodb_adaptive_checkpoint,
+  &sys_innodb_show_locks_held,
+  &sys_innodb_show_verbose_locks,
 #endif
   &sys_trust_routine_creators,
   &sys_trust_function_creators,
@@ -1008,6 +1016,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 },