Merge lp:~percona-dev/percona-server/release-5.1.46-11-bugfix569288 into lp:percona-server/release-5.1.46-11

Proposed by Oleg Tsarev
Status: Merged
Merged at revision: 9
Proposed branch: lp:~percona-dev/percona-server/release-5.1.46-11-bugfix569288
Merge into: lp:percona-server/release-5.1.46-11
Diff against target: 196 lines (+169/-0)
5 files modified
COPYING.innodb-deadlock-count-patch (+30/-0)
innodb_deadlock_count.patch (+61/-0)
mysql-test/percona_innodb_deadlock_count.result (+31/-0)
mysql-test/percona_innodb_deadlock_count.test (+46/-0)
series (+1/-0)
To merge this branch: bzr merge lp:~percona-dev/percona-server/release-5.1.46-11-bugfix569288
Reviewer Review Type Date Requested Status
Yasufumi Kinoshita (community) Approve
Vadim Tkachenko Approve
Review via email: mp+25962@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

It is OK for me. Yasufumi what do you think ?

review: Approve
Revision history for this message
Yasufumi Kinoshita (yasufumi-kinoshita) wrote :

At least, this change doesn't affect to the other codes. It seems to be safe.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'COPYING.innodb-deadlock-count-patch'
2--- COPYING.innodb-deadlock-count-patch 1970-01-01 00:00:00 +0000
3+++ COPYING.innodb-deadlock-count-patch 2010-05-25 16:06:36 +0000
4@@ -0,0 +1,30 @@
5+Portions of this software contain modifications contributed by Eric Bergen.
6+These contributions are used with the following license:
7+
8+Copyright (c) 2010, Eric Bergen. All rights reserved.
9+
10+Redistribution and use in source and binary forms, with or without
11+modification, are permitted provided that the following conditions
12+are met:
13+ * Redistributions of source code must retain the above copyright
14+ notice, this list of conditions and the following disclaimer.
15+ * Redistributions in binary form must reproduce the above
16+ copyright notice, this list of conditions and the following
17+ disclaimer in the documentation and/or other materials
18+ provided with the distribution.
19+ * Neither the name of the Eric Bergen. nor the names of its
20+ contributors may be used to endorse or promote products
21+ derived from this software without specific prior written
22+ permission.
23+
24+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
36=== added file 'innodb_deadlock_count.patch'
37--- innodb_deadlock_count.patch 1970-01-01 00:00:00 +0000
38+++ innodb_deadlock_count.patch 2010-05-25 16:06:36 +0000
39@@ -0,0 +1,61 @@
40+--- mysql-5.1.46.orig/storage/innodb_plugin/handler/ha_innodb.cc 2010-05-25 00:44:19.000000000 +0400
41++++ mysql-5.1.46/storage/innodb_plugin/handler/ha_innodb.cc 2010-05-25 01:01:55.000000000 +0400
42+@@ -539,6 +539,8 @@
43+ (char*) &export_vars.innodb_data_written, SHOW_LONG},
44+ {"dblwr_pages_written",
45+ (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
46++ {"deadlocks",
47++ (char*) &export_vars.innodb_deadlocks, SHOW_LONG},
48+ {"dblwr_writes",
49+ (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
50+ {"dict_tables",
51+--- mysql-5.1.46.orig/storage/innodb_plugin/include/lock0lock.h 2010-04-06 18:07:12.000000000 +0400
52++++ mysql-5.1.46/storage/innodb_plugin/include/lock0lock.h 2010-05-25 00:52:34.000000000 +0400
53+@@ -43,6 +43,7 @@
54+ #endif /* UNIV_DEBUG */
55+ /* Buffer for storing information about the most recent deadlock error */
56+ extern FILE* lock_latest_err_file;
57++extern ulint srv_n_lock_deadlock_count;
58+
59+ /*********************************************************************//**
60+ Gets the size of a lock struct.
61+--- mysql-5.1.46.orig/storage/innodb_plugin/include/srv0srv.h 2010-05-25 00:44:19.000000000 +0400
62++++ mysql-5.1.46/storage/innodb_plugin/include/srv0srv.h 2010-05-25 00:56:58.000000000 +0400
63+@@ -660,6 +660,7 @@
64+ ulint innodb_buffer_pool_write_requests;/*!< srv_buf_pool_write_requests */
65+ ulint innodb_buffer_pool_read_ahead; /*!< srv_read_ahead */
66+ ulint innodb_buffer_pool_read_ahead_evicted;/*!< srv_read_ahead evicted*/
67++ ulint innodb_deadlocks; /* ??? */
68+ ulint innodb_dblwr_pages_written; /*!< srv_dblwr_pages_written */
69+ ulint innodb_dblwr_writes; /*!< srv_dblwr_writes */
70+ ibool innodb_have_atomic_builtins; /*!< HAVE_ATOMIC_BUILTINS */
71+--- mysql-5.1.46/storage/innodb_plugin/lock/lock0lock.c 2010-05-25 00:57:00.000000000 +0400
72++++ mysql-5.1.46/storage/innodb_plugin/lock/lock0lock.c 2010-05-25 16:53:32.000000000 +0400
73+@@ -3322,6 +3322,7 @@
74+ break;
75+
76+ case LOCK_VICTIM_IS_START:
77++ srv_n_lock_deadlock_count++;
78+ fputs("*** WE ROLL BACK TRANSACTION (2)\n",
79+ lock_latest_err_file);
80+ break;
81+--- mysql-5.1.46.orig/storage/innodb_plugin/srv/srv0srv.c 2010-05-25 00:44:19.000000000 +0400
82++++ mysql-5.1.46/storage/innodb_plugin/srv/srv0srv.c 2010-05-25 00:59:29.000000000 +0400
83+@@ -433,7 +433,7 @@
84+ static ulint srv_n_rows_updated_old = 0;
85+ static ulint srv_n_rows_deleted_old = 0;
86+ static ulint srv_n_rows_read_old = 0;
87+-
88++UNIV_INTERN ulint srv_n_lock_deadlock_count = 0;
89+ UNIV_INTERN ulint srv_n_lock_wait_count = 0;
90+ UNIV_INTERN ulint srv_n_lock_wait_current_count = 0;
91+ UNIV_INTERN ib_int64_t srv_n_lock_wait_time = 0;
92+@@ -2140,6 +2140,8 @@
93+ = UT_LIST_GET_LEN(buf_pool->flush_list);
94+ export_vars.innodb_buffer_pool_pages_free
95+ = UT_LIST_GET_LEN(buf_pool->free);
96++ export_vars.innodb_deadlocks
97++ = srv_n_lock_deadlock_count;
98+ #ifdef UNIV_DEBUG
99+ export_vars.innodb_buffer_pool_pages_latched
100+ = buf_get_latched_pages_number();
101
102=== added file 'mysql-test/percona_innodb_deadlock_count.result'
103--- mysql-test/percona_innodb_deadlock_count.result 1970-01-01 00:00:00 +0000
104+++ mysql-test/percona_innodb_deadlock_count.result 2010-05-25 16:06:36 +0000
105@@ -0,0 +1,31 @@
106+# Establish connection con1 (user=root)
107+# Establish connection con2 (user=root)
108+# Establish connection con3 (user=root)
109+# Drop test table
110+drop table if exists t;
111+# Create test table
112+create table t(a INT PRIMARY KEY, b INT) engine=InnoDB;
113+# Insert two rows to test table
114+insert into t values(2,1);
115+insert into t values(1,2);
116+show global status like 'Innodb_deadlocks';
117+Variable_name Value
118+Innodb_deadlocks 0
119+# Switch to connection con1
120+BEGIN;
121+SELECT b FROM t WHERE a=1 FOR UPDATE;
122+b
123+2
124+# Switch to connection con2
125+BEGIN;
126+SELECT b FROM t WHERE a=2 FOR UPDATE;
127+b
128+1
129+# Switch to connection con1
130+SELECT b FROM t WHERE a=2 FOR UPDATE;
131+# Switch to connection con2
132+SELECT b FROM t WHERE a=1 FOR UPDATE;
133+# Switch to connection con3
134+show global status like 'Innodb_deadlocks';
135+Variable_name Value
136+Innodb_deadlocks 1
137
138=== added file 'mysql-test/percona_innodb_deadlock_count.test'
139--- mysql-test/percona_innodb_deadlock_count.test 1970-01-01 00:00:00 +0000
140+++ mysql-test/percona_innodb_deadlock_count.test 2010-05-25 16:06:36 +0000
141@@ -0,0 +1,46 @@
142+--source include/have_innodb.inc
143+--echo # Establish connection con1 (user=root)
144+connect (con1,localhost,root,,);
145+--echo # Establish connection con2 (user=root)
146+connect (con2,localhost,root,,);
147+--echo # Establish connection con3 (user=root)
148+connect (con3,localhost,root,,);
149+--echo # Drop test table
150+ --disable_warnings
151+drop table if exists t;
152+--enable_warnings
153+disable_abort_on_error;
154+
155+--echo # Create test table
156+create table t(a INT PRIMARY KEY, b INT) engine=InnoDB;
157+--echo # Insert two rows to test table
158+insert into t values(2,1);
159+insert into t values(1,2);
160+
161+#set global innodb_lock_wait_timeout=2;
162+
163+#--echo # Look for deadlock count
164+show global status like 'Innodb_deadlocks';
165+
166+--echo # Switch to connection con1
167+connection con1;
168+BEGIN; SELECT b FROM t WHERE a=1 FOR UPDATE;
169+
170+#show engine innodb status;
171+
172+--echo # Switch to connection con2
173+connection con2;
174+BEGIN; SELECT b FROM t WHERE a=2 FOR UPDATE;
175+
176+--echo # Switch to connection con1
177+connection con1;
178+SEND SELECT b FROM t WHERE a=2 FOR UPDATE;
179+
180+--echo # Switch to connection con2
181+connection con2;
182+SEND SELECT b FROM t WHERE a=1 FOR UPDATE;
183+
184+--echo # Switch to connection con3
185+connection con3;
186+show global status like 'Innodb_deadlocks';
187+
188
189=== modified file 'series'
190--- series 2010-05-21 09:44:50 +0000
191+++ series 2010-05-25 16:06:36 +0000
192@@ -36,3 +36,4 @@
193 innodb_fix_misc.patch
194 innodb_adjust_defaults.patch
195 mysql-test.diff
196+innodb_deadlock_count.patch

Subscribers

People subscribed via source and target branches

to all changes: