Merge lp:~laurynas-biveinis/percona-server/bug1064326-5.5 into lp:percona-server/5.5

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Stewart Smith
Approved revision: 316
Merged at revision: 338
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1064326-5.5
Merge into: lp:percona-server/5.5
Prerequisite: lp:~laurynas-biveinis/percona-server/bug890404-5.5
Diff against target: 442 lines (+128/-122)
11 files modified
Percona-Server/mysql-test/r/percona_innodb_fake_changes_locks.result (+0/-19)
Percona-Server/mysql-test/r/percona_server_variables_debug.result (+1/-0)
Percona-Server/mysql-test/r/percona_server_variables_release.result (+1/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_locking_fake_changes_basic.result (+52/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_locking_fake_changes_basic.test (+44/-0)
Percona-Server/mysql-test/t/percona_innodb_fake_changes.test (+0/-75)
Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test (+0/-24)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+8/-0)
Percona-Server/storage/innobase/include/srv0srv.h (+4/-0)
Percona-Server/storage/innobase/lock/lock0lock.c (+14/-4)
Percona-Server/storage/innobase/srv/srv0srv.c (+4/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1064326-5.5
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+129425@code.launchpad.net

Description of the change

Merge bug 1064326 fix from 5.1.

Resolve fileids and adjust InnoDB check for
percona_innodb_fake_changes_locks testcase, add
sys_vars/innodb_fake_changes_locks_basic test.

http://jenkins.percona.com/job/percona-server-5.5-param/543/

26611

To post a comment you must log in.
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'Percona-Server/mysql-test/r/percona_innodb_fake_changes_locks.result'
2--- Percona-Server/mysql-test/r/percona_innodb_fake_changes_locks.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/r/percona_innodb_fake_changes_locks.result 2012-10-12 13:12:20 +0000
4@@ -0,0 +1,83 @@
5+DROP TABLE IF EXISTS t1, t2;
6+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
7+INSERT INTO t1 VALUES (1);
8+CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
9+INSERT INTO t2 VALUES (1, 1);
10+# Verifying that X_LOCK not acquired
11+SET autocommit=0;
12+SET innodb_fake_changes=1;
13+BEGIN;
14+SELECT * FROM t1 FOR UPDATE;
15+a
16+1
17+SET innodb_lock_wait_timeout=3;
18+UPDATE t1 SET a=2;
19+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
20+SELECT * FROM t1 LOCK IN SHARE MODE;
21+a
22+1
23+ROLLBACK;
24+# Confirm no lock wait timeouts when innodb_locking_fake_changes=0
25+SET GLOBAL innodb_locking_fake_changes=0;
26+BEGIN;
27+SELECT * FROM t1 FOR UPDATE;
28+a
29+1
30+BEGIN;
31+UPDATE t1 SET a=3 WHERE a=1;
32+SELECT * FROM t1 LOCK IN SHARE MODE;
33+a
34+3
35+ROLLBACK;
36+ROLLBACK;
37+# Confirm that fake UPDATE does not hold a lock
38+BEGIN;
39+SELECT * FROM t1 FOR UPDATE;
40+a
41+1
42+BEGIN;
43+UPDATE t1 SET a=3 WHERE a=1;
44+ROLLBACK;
45+ROLLBACK;
46+BEGIN;
47+UPDATE t1 SET a=3 WHERE a=1;
48+BEGIN;
49+UPDATE t1 SET a=3 WHERE a=1;
50+ROLLBACK;
51+ROLLBACK;
52+# Confirm that fake INSERT does not hold a lock
53+BEGIN;
54+INSERT INTO t1 VALUES(4);
55+BEGIN;
56+INSERT INTO t1 VALUES(4);
57+ROLLBACK;
58+ROLLBACK;
59+# Confirm that fake DELETE does not hold a lock
60+BEGIN;
61+DELETE FROM t1 WHERE a=1;
62+BEGIN;
63+DELETE FROM t1 WHERE a=1;
64+ROLLBACK;
65+ROLLBACK;
66+# Confirm that fake REPLACE does not hold a lock
67+BEGIN;
68+REPLACE INTO t2 VALUES(1, 2);
69+BEGIN;
70+REPLACE INTO t2 VALUES(1, 2);
71+ROLLBACK;
72+ROLLBACK;
73+SET innodb_fake_changes=default;
74+SET GLOBAL innodb_locking_fake_changes=default;
75+# Verify that the fake changes to t1 did not leak through
76+CHECK TABLE t1;
77+Table Op Msg_type Msg_text
78+test.t1 check status OK
79+should_be_1
80+1
81+# Verify that the fake changes to t2 did not leak through
82+CHECK TABLE t2;
83+Table Op Msg_type Msg_text
84+test.t2 check status OK
85+should_be_1
86+1
87+DROP TABLE t1, t2;
88
89=== removed file 'Percona-Server/mysql-test/r/percona_innodb_fake_changes_locks.result'
90--- Percona-Server/mysql-test/r/percona_innodb_fake_changes_locks.result 2012-04-18 23:25:36 +0000
91+++ Percona-Server/mysql-test/r/percona_innodb_fake_changes_locks.result 1970-01-01 00:00:00 +0000
92@@ -1,19 +0,0 @@
93-DROP TABLE IF EXISTS t1;
94-# Verifying that X_LOCK not acquired
95-CREATE TABLE t1 (a INT) ENGINE=InnoDB;
96-INSERT INTO t1 VALUES (1);
97-SET autocommit=0;
98-SET innodb_fake_changes=1;
99-BEGIN;
100-SELECT * FROM t1 FOR UPDATE;
101-a
102-1
103-SET innodb_lock_wait_timeout=3;
104-UPDATE t1 SET a=2;
105-ERROR HY000: Lock wait timeout exceeded; try restarting transaction
106-SELECT * FROM t1 LOCK IN SHARE MODE;
107-a
108-1
109-ROLLBACK;
110-SET innodb_fake_changes=default;
111-DROP TABLE t1;
112
113=== modified file 'Percona-Server/mysql-test/r/percona_server_variables_debug.result'
114--- Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-10-12 06:24:13 +0000
115+++ Percona-Server/mysql-test/r/percona_server_variables_debug.result 2012-10-12 13:12:20 +0000
116@@ -125,6 +125,7 @@
117 INNODB_KILL_IDLE_TRANSACTION
118 INNODB_LARGE_PREFIX
119 INNODB_LAZY_DROP_TABLE
120+INNODB_LOCKING_FAKE_CHANGES
121 INNODB_LOCKS_UNSAFE_FOR_BINLOG
122 INNODB_LOCK_WAIT_TIMEOUT
123 INNODB_LOG_BLOCK_SIZE
124
125=== modified file 'Percona-Server/mysql-test/r/percona_server_variables_release.result'
126--- Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-09-28 01:36:45 +0000
127+++ Percona-Server/mysql-test/r/percona_server_variables_release.result 2012-10-12 13:12:20 +0000
128@@ -122,6 +122,7 @@
129 INNODB_KILL_IDLE_TRANSACTION
130 INNODB_LARGE_PREFIX
131 INNODB_LAZY_DROP_TABLE
132+INNODB_LOCKING_FAKE_CHANGES
133 INNODB_LOCKS_UNSAFE_FOR_BINLOG
134 INNODB_LOCK_WAIT_TIMEOUT
135 INNODB_LOG_BLOCK_SIZE
136
137=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_locking_fake_changes_basic.result'
138--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_locking_fake_changes_basic.result 1970-01-01 00:00:00 +0000
139+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_locking_fake_changes_basic.result 2012-10-12 13:12:20 +0000
140@@ -0,0 +1,52 @@
141+SET @start_global_value = @@global.innodb_locking_fake_changes;
142+SELECT @start_global_values;
143+@start_global_values
144+NULL
145+SELECT COUNT(@@GLOBAL.innodb_locking_fake_changes) AS should_be_1;
146+should_be_1
147+1
148+SET @@global.innodb_locking_fake_changes = 0;
149+SELECT @@global.innodb_locking_fake_changes;
150+@@global.innodb_locking_fake_changes
151+0
152+SET @@global.innodb_locking_fake_changes ='On' ;
153+SELECT @@global.innodb_locking_fake_changes;
154+@@global.innodb_locking_fake_changes
155+1
156+SET @@global.innodb_locking_fake_changes ='Off' ;
157+SELECT @@global.innodb_locking_fake_changes;
158+@@global.innodb_locking_fake_changes
159+0
160+SET @@global.innodb_locking_fake_changes = 1;
161+SELECT @@global.innodb_locking_fake_changes;
162+@@global.innodb_locking_fake_changes
163+1
164+SELECT IF(@@GLOBAL.innodb_locking_fake_changes,'ON','OFF') = VARIABLE_VALUE AS should_be_1
165+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
166+WHERE VARIABLE_NAME='innodb_locking_fake_changes';
167+should_be_1
168+1
169+SELECT COUNT(VARIABLE_VALUE) AS should_be_1
170+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
171+WHERE VARIABLE_NAME='innodb_locking_fake_changes';
172+should_be_1
173+1
174+SELECT @@innodb_locking_fake_changes = @@GLOBAL.innodb_locking_fake_changes;
175+@@innodb_locking_fake_changes = @@GLOBAL.innodb_locking_fake_changes
176+1
177+SELECT COUNT(@@innodb_locking_fake_changes) AS should_be_1;
178+should_be_1
179+1
180+SELECT COUNT(@@local.innodb_locking_fake_changes);
181+ERROR HY000: Variable 'innodb_locking_fake_changes' is a GLOBAL variable
182+SELECT COUNT(@@SESSION.innodb_locking_fake_changes);
183+ERROR HY000: Variable 'innodb_locking_fake_changes' is a GLOBAL variable
184+SELECT COUNT(@@GLOBAL.innodb_locking_fake_changes) AS should_be_1;
185+should_be_1
186+1
187+SELECT innodb_locking_fake_changes = @@SESSION.innodb_locking_fake_changes;
188+ERROR 42S22: Unknown column 'innodb_locking_fake_changes' in 'field list'
189+SET @@global.innodb_locking_fake_changes = @start_global_value;
190+SELECT @@global.innodb_locking_fake_changes;
191+@@global.innodb_locking_fake_changes
192+1
193
194=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_locking_fake_changes_basic.test'
195--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_locking_fake_changes_basic.test 1970-01-01 00:00:00 +0000
196+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_locking_fake_changes_basic.test 2012-10-12 13:12:20 +0000
197@@ -0,0 +1,44 @@
198+# sys_vars suite test for innodb_locking_fake_changes
199+
200+SET @start_global_value = @@global.innodb_locking_fake_changes;
201+SELECT @start_global_values;
202+
203+SELECT COUNT(@@GLOBAL.innodb_locking_fake_changes) AS should_be_1;
204+
205+SET @@global.innodb_locking_fake_changes = 0;
206+SELECT @@global.innodb_locking_fake_changes;
207+
208+SET @@global.innodb_locking_fake_changes ='On' ;
209+SELECT @@global.innodb_locking_fake_changes;
210+
211+SET @@global.innodb_locking_fake_changes ='Off' ;
212+SELECT @@global.innodb_locking_fake_changes;
213+
214+SET @@global.innodb_locking_fake_changes = 1;
215+SELECT @@global.innodb_locking_fake_changes;
216+
217+SELECT IF(@@GLOBAL.innodb_locking_fake_changes,'ON','OFF') = VARIABLE_VALUE AS should_be_1
218+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
219+WHERE VARIABLE_NAME='innodb_locking_fake_changes';
220+
221+SELECT COUNT(VARIABLE_VALUE) AS should_be_1
222+FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
223+WHERE VARIABLE_NAME='innodb_locking_fake_changes';
224+
225+SELECT @@innodb_locking_fake_changes = @@GLOBAL.innodb_locking_fake_changes;
226+
227+SELECT COUNT(@@innodb_locking_fake_changes) AS should_be_1;
228+
229+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
230+SELECT COUNT(@@local.innodb_locking_fake_changes);
231+
232+--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
233+SELECT COUNT(@@SESSION.innodb_locking_fake_changes);
234+
235+SELECT COUNT(@@GLOBAL.innodb_locking_fake_changes) AS should_be_1;
236+
237+--Error ER_BAD_FIELD_ERROR
238+SELECT innodb_locking_fake_changes = @@SESSION.innodb_locking_fake_changes;
239+
240+SET @@global.innodb_locking_fake_changes = @start_global_value;
241+SELECT @@global.innodb_locking_fake_changes;
242
243=== removed file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes.test'
244--- Percona-Server/mysql-test/t/percona_innodb_fake_changes.test 2012-10-12 13:12:19 +0000
245+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes.test 1970-01-01 00:00:00 +0000
246@@ -1,75 +0,0 @@
247---source include/have_innodb.inc
248-
249---disable_warnings
250-DROP TABLE IF EXISTS t1, t2, t3;
251---enable_warnings
252-
253-
254---echo # Checking variables
255-SHOW VARIABLES LIKE 'innodb_fake_changes';
256-SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='innodb_fake_changes';
257-SET innodb_fake_changes=1;
258-SHOW VARIABLES LIKE 'innodb_fake_changes';
259-SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='innodb_fake_changes';
260-SET innodb_fake_changes=default;
261-SHOW VARIABLES LIKE 'innodb_fake_changes';
262-SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='innodb_fake_changes';
263-
264---echo # Explicit COMMIT should fail when innodb_fake_changes is enabled
265---echo # DML should be fine
266-CREATE TABLE t1 (a INT) ENGINE=InnoDB;
267-INSERT INTO t1 VALUES (1);
268-let $t1_checksum_1= `CHECKSUM TABLE t1 EXTENDED`;
269-SET autocommit=0;
270-SET innodb_fake_changes=1;
271-BEGIN;
272-INSERT INTO t1 VALUES (2);
273-UPDATE t1 SET a=0;
274-DELETE FROM t1 LIMIT 1;
275-SELECT * FROM t1;
276---error 1180
277-COMMIT;
278-SET innodb_fake_changes=default;
279---echo # Verify that the fake changes to t1 did not leak through
280-CHECK TABLE t1;
281-let $t1_checksum_2= `CHECKSUM TABLE t1 EXTENDED`;
282---disable_query_log
283-eval SELECT "$t1_checksum_1" LIKE "$t1_checksum_2" AS should_be_1;
284---enable_query_log
285-DROP TABLE t1;
286-
287---echo # DDL must result in error
288-CREATE TABLE t1 (a INT) ENGINE=InnoDB;
289-SET autocommit=0;
290-SET innodb_fake_changes=1;
291-BEGIN;
292---error 1005
293-CREATE TABLE t2 (a INT) ENGINE=InnoDB;
294---error 1051
295-DROP TABLE t1;
296---error 1180
297-TRUNCATE TABLE t1;
298---error 1180
299-ALTER TABLE t1 ENGINE=MyISAM;
300-ROLLBACK;
301-
302-# Test for bug 890404: uninitialized value warning in btr_cur_pessimistic_update
303-SET innodb_fake_changes=0;
304-CREATE TABLE t3 (a INT primary key, b text) ENGINE=InnoDB;
305-INSERT INTO t3 VALUES (1,'');
306-COMMIT;
307-let $t3_checksum_1= `CHECKSUM TABLE t3 EXTENDED`;
308-SET innodb_fake_changes=1;
309-
310-UPDATE t3 set b=lpad('b',11000,'c') where a=1;
311---error ER_ERROR_DURING_COMMIT
312-COMMIT;
313-
314-SET innodb_fake_changes=default;
315---echo # Verify that the fake changes to t3 did not leak through
316-CHECK TABLE t3;
317-let $t3_checksum_2= `CHECKSUM TABLE t3 EXTENDED`;
318---disable_query_log
319-eval SELECT "$t3_checksum_1" LIKE "$t3_checksum_2" AS should_be_1;
320---enable_query_log
321-DROP TABLE t1, t3;
322
323=== removed file 'Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test'
324--- Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test 2012-04-18 23:25:36 +0000
325+++ Percona-Server/mysql-test/t/percona_innodb_fake_changes_locks.test 1970-01-01 00:00:00 +0000
326@@ -1,24 +0,0 @@
327---source include/have_innodb.inc
328-
329---disable_warnings
330-DROP TABLE IF EXISTS t1;
331---enable_warnings
332-
333---echo # Verifying that X_LOCK not acquired
334-CREATE TABLE t1 (a INT) ENGINE=InnoDB;
335-INSERT INTO t1 VALUES (1);
336---connect (conn1,localhost,root,,)
337---connection conn1
338-SET autocommit=0;
339-SET innodb_fake_changes=1;
340-BEGIN;
341-SELECT * FROM t1 FOR UPDATE;
342---connection default
343-SET innodb_lock_wait_timeout=3;
344---error 1205
345-UPDATE t1 SET a=2;
346-SELECT * FROM t1 LOCK IN SHARE MODE;
347---connection conn1
348-ROLLBACK;
349-SET innodb_fake_changes=default;
350-DROP TABLE t1;
351
352=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
353--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-10-01 00:49:13 +0000
354+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-10-12 13:12:20 +0000
355@@ -12868,6 +12868,13 @@
356 "e.g. for http://bugs.mysql.com/51325",
357 NULL, NULL, 0, 0, 1, 0);
358
359+static MYSQL_SYSVAR_BOOL(locking_fake_changes, srv_fake_changes_locks,
360+ PLUGIN_VAR_NOCMDARG,
361+ "###EXPERIMENTAL### if enabled, transactions will get S row locks instead "
362+ "of X locks for fake changes. If disabled, fake change transactions will "
363+ "not take any locks at all.",
364+ NULL, NULL, TRUE);
365+
366 static struct st_mysql_sys_var* innobase_system_variables[]= {
367 MYSQL_SYSVAR(page_size),
368 MYSQL_SYSVAR(log_block_size),
369@@ -12976,6 +12983,7 @@
370 MYSQL_SYSVAR(corrupt_table_action),
371 MYSQL_SYSVAR(lazy_drop_table),
372 MYSQL_SYSVAR(fake_changes),
373+ MYSQL_SYSVAR(locking_fake_changes),
374 MYSQL_SYSVAR(merge_sort_block_size),
375 NULL
376 };
377
378=== modified file 'Percona-Server/storage/innobase/include/srv0srv.h'
379--- Percona-Server/storage/innobase/include/srv0srv.h 2012-09-28 07:53:51 +0000
380+++ Percona-Server/storage/innobase/include/srv0srv.h 2012-10-12 13:12:20 +0000
381@@ -391,6 +391,10 @@
382 /** Whether startup should be blocked until buffer pool is fully restored */
383 extern ibool srv_blocking_lru_restore;
384
385+/** When TRUE, fake change transcations take S rather than X row locks.
386+When FALSE, row locks are not taken at all. */
387+extern my_bool srv_fake_changes_locks;
388+
389 /** Status variables to be passed to MySQL */
390 typedef struct export_var_struct export_struc;
391
392
393=== modified file 'Percona-Server/storage/innobase/lock/lock0lock.c'
394--- Percona-Server/storage/innobase/lock/lock0lock.c 2012-06-01 12:15:25 +0000
395+++ Percona-Server/storage/innobase/lock/lock0lock.c 2012-10-12 13:12:20 +0000
396@@ -5481,8 +5481,13 @@
397 return(DB_SUCCESS);
398 }
399
400- if (thr && thr_get_trx(thr)->fake_changes && mode == LOCK_X) {
401- mode = LOCK_S;
402+ if (UNIV_UNLIKELY((thr && thr_get_trx(thr)->fake_changes))) {
403+ if (!srv_fake_changes_locks) {
404+ return(DB_SUCCESS);
405+ }
406+ if (mode == LOCK_X) {
407+ mode = LOCK_S;
408+ }
409 }
410
411 heap_no = page_rec_get_heap_no(rec);
412@@ -5561,8 +5566,13 @@
413 return(DB_SUCCESS);
414 }
415
416- if (thr && thr_get_trx(thr)->fake_changes && mode == LOCK_X) {
417- mode = LOCK_S;
418+ if (UNIV_UNLIKELY((thr && thr_get_trx(thr)->fake_changes))) {
419+ if (!srv_fake_changes_locks) {
420+ return(DB_SUCCESS);
421+ }
422+ if (mode == LOCK_X) {
423+ mode = LOCK_S;
424+ }
425 }
426
427 heap_no = page_rec_get_heap_no(rec);
428
429=== modified file 'Percona-Server/storage/innobase/srv/srv0srv.c'
430--- Percona-Server/storage/innobase/srv/srv0srv.c 2012-09-28 07:53:51 +0000
431+++ Percona-Server/storage/innobase/srv/srv0srv.c 2012-10-12 13:12:20 +0000
432@@ -181,6 +181,10 @@
433
434 UNIV_INTERN ulonglong srv_changed_pages_limit = 0;
435
436+/** When TRUE, fake change transcations take S rather than X row locks.
437+ When FALSE, row locks are not taken at all. */
438+UNIV_INTERN my_bool srv_fake_changes_locks = TRUE;
439+
440 /* if TRUE, then we auto-extend the last data file */
441 UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE;
442 /* if != 0, this tells the max size auto-extending may increase the

Subscribers

People subscribed via source and target branches