Merge lp:~laurynas-biveinis/percona-server/BT-16274-bug1111226-5.1 into lp:percona-server/5.1

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Stewart Smith
Approved revision: 526
Merged at revision: 527
Proposed branch: lp:~laurynas-biveinis/percona-server/BT-16274-bug1111226-5.1
Merge into: lp:percona-server/5.1
Diff against target: 168 lines (+104/-15)
4 files modified
Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_debug.result (+23/-0)
Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug-master.opt (+1/-0)
Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug.test (+56/-0)
Percona-Server/storage/innodb_plugin/log/log0online.c (+24/-15)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/BT-16274-bug1111226-5.1
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
George Ormond Lorch III g2 Approve
Laurynas Biveinis Pending
Review via email: mp+147066@code.launchpad.net

This proposal supersedes a proposal from 2013-01-31.

Description of the change

2nd MP: unify 5.1 and 5.5 tests.
http://jenkins.percona.com/job/percona-server-5.1-param/520/

Fix bug 1111226 for 5.1
No BT or ST, but 16274 QA

Fix bug 1111226 (Writing larger than 4GB bitmap file fails; bitmap
write error causes heap corruption).

The first issue is incorrect higher 32 bits of write offset
calculation: the 64-bit offset was shifted to the left instead of the
right, fixed trivially.

The second issue is that if a bitmap page write fails (for example,
due to the condition above), then log_online_write_bitmap() exits
prematurely with a return code signalling error. But, if at least one
bitmap page was written successfully, then the written bitmap tree
nodes will be doubly pointed to: from the bitmap tree itself and from
the free node list. This will cause a heap corruption on the log
following thread shutdown (which happens immediatelly in the case of
bitmap write error).

Fixed by keeping iterating over the bitmap tree in case of error, but
skipping the actual write. This way all the tree nodes are moved to
free list for the subsequent cleanup.

Add a write failure injection site and a new testcase
percona_changed_page_debug.

To post a comment you must log in.
Revision history for this message
George Ormond Lorch III (gl-az) wrote : Posted in a previous version of this proposal

percona_changed_page_bmp_debug.test is slightly different from 5.5 MP in the way the server restarts are structured and order of:
RESET CHANGED_PAGE_BITMAPS;
CREATE TABLE t1 (x INT) ENGINE=InnoDB;

Is this intentional?

review: Needs Information (g2)
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Discussion on the 5.5 MP.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) : Posted in a previous version of this proposal
review: Needs Fixing
Revision history for this message
George Ormond Lorch III (gl-az) :
review: Approve (g2)
Revision history for this message
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/suite/innodb_plugin/r/percona_changed_page_bmp_debug.result'
2--- Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_debug.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_debug.result 2013-02-07 10:52:23 +0000
4@@ -0,0 +1,23 @@
5+DROP TABLE IF EXISTS t1;
6+call mtr.add_suppression("InnoDB: Error: log tracking bitmap write failed, stopping log tracking thread!");
7+1st restart
8+RESET CHANGED_PAGE_BITMAPS;
9+CREATE TABLE t1 (x INT) ENGINE=InnoDB;
10+2nd restart
11+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
12+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
13+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
14+INSERT INTO t1 SELECT x FROM t1;
15+INSERT INTO t1 SELECT x FROM t1;
16+INSERT INTO t1 SELECT x FROM t1;
17+INSERT INTO t1 SELECT x FROM t1;
18+INSERT INTO t1 SELECT x FROM t1;
19+INSERT INTO t1 SELECT x FROM t1;
20+INSERT INTO t1 SELECT x FROM t1;
21+INSERT INTO t1 SELECT x FROM t1;
22+INSERT INTO t1 SELECT x FROM t1;
23+INSERT INTO t1 SELECT x FROM t1;
24+INSERT INTO t1 SELECT x FROM t1;
25+INSERT INTO t1 SELECT x FROM t1;
26+3rd restart
27+DROP TABLE t1;
28
29=== added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug-master.opt'
30--- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug-master.opt 1970-01-01 00:00:00 +0000
31+++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug-master.opt 2013-02-07 10:52:23 +0000
32@@ -0,0 +1,1 @@
33+--innodb_track_changed_pages=TRUE --innodb_log_file_size=1M
34
35=== added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug.test'
36--- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug.test 1970-01-01 00:00:00 +0000
37+++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug.test 2013-02-07 10:52:23 +0000
38@@ -0,0 +1,56 @@
39+#
40+# Non-crash tests for the changed page bitmaps that require debug builds
41+#
42+--source include/have_debug.inc
43+--source include/have_innodb_plugin.inc
44+
45+--disable_warnings
46+DROP TABLE IF EXISTS t1;
47+--enable_warnings
48+
49+let $MYSQLD_DATADIR= `select @@datadir`;
50+
51+call mtr.add_suppression("InnoDB: Error: log tracking bitmap write failed, stopping log tracking thread!");
52+
53+--echo 1st restart
54+--source include/restart_mysqld.inc
55+RESET CHANGED_PAGE_BITMAPS;
56+CREATE TABLE t1 (x INT) ENGINE=InnoDB;
57+
58+#
59+# Test for bug 1111226: test that bitmap write errors are handled gracefully
60+#
61+
62+# Setup an error on bitmap write
63+--echo 2nd restart
64+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
65+--shutdown_server 10
66+--source include/wait_until_disconnected.inc
67+--enable_reconnect
68+--exec echo "restart:-#d,bitmap_page_write_error" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
69+--source include/wait_until_connected_again.inc
70+
71+# Generate log data that is larger than the log capacity
72+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
73+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
74+INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
75+INSERT INTO t1 SELECT x FROM t1;
76+INSERT INTO t1 SELECT x FROM t1;
77+INSERT INTO t1 SELECT x FROM t1;
78+INSERT INTO t1 SELECT x FROM t1;
79+INSERT INTO t1 SELECT x FROM t1;
80+INSERT INTO t1 SELECT x FROM t1;
81+INSERT INTO t1 SELECT x FROM t1;
82+INSERT INTO t1 SELECT x FROM t1;
83+INSERT INTO t1 SELECT x FROM t1;
84+INSERT INTO t1 SELECT x FROM t1;
85+INSERT INTO t1 SELECT x FROM t1;
86+INSERT INTO t1 SELECT x FROM t1;
87+
88+# At this point the log tracker thread should have quit
89+# TODO: test its status through I_S query once the table is implemented
90+
91+--echo 3rd restart
92+--source include/restart_mysqld.inc
93+
94+DROP TABLE t1;
95
96=== modified file 'Percona-Server/storage/innodb_plugin/log/log0online.c'
97--- Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-07 05:14:23 +0000
98+++ Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-07 10:52:23 +0000
99@@ -1073,10 +1073,13 @@
100
101 ut_ad(mutex_own(&log_bmp_sys->mutex));
102
103+ /* Simulate a write error */
104+ DBUG_EXECUTE_IF("bitmap_page_write_error", return FALSE;);
105+
106 success = os_file_write(log_bmp_sys->out.name, log_bmp_sys->out.file,
107 block,
108 (ulint)(log_bmp_sys->out.offset & 0xFFFFFFFF),
109- (ulint)(log_bmp_sys->out.offset << 32),
110+ (ulint)(log_bmp_sys->out.offset >> 32),
111 MODIFIED_PAGE_BLOCK_SIZE);
112 if (UNIV_UNLIKELY(!success)) {
113
114@@ -1119,6 +1122,7 @@
115 {
116 ib_rbt_node_t *bmp_tree_node;
117 const ib_rbt_node_t *last_bmp_tree_node;
118+ ibool success = TRUE;
119
120 ut_ad(mutex_own(&log_bmp_sys->mutex));
121
122@@ -1136,19 +1140,24 @@
123
124 byte *page = rbt_value(byte, bmp_tree_node);
125
126- if (bmp_tree_node == last_bmp_tree_node) {
127- mach_write_to_4(page + MODIFIED_PAGE_IS_LAST_BLOCK, 1);
128- }
129-
130- mach_write_ull(page + MODIFIED_PAGE_START_LSN,
131- log_bmp_sys->start_lsn);
132- mach_write_ull(page + MODIFIED_PAGE_END_LSN,
133- log_bmp_sys->end_lsn);
134- mach_write_to_4(page + MODIFIED_PAGE_BLOCK_CHECKSUM,
135- log_online_calc_checksum(page));
136-
137- if (!log_online_write_bitmap_page(page)) {
138- return FALSE;
139+ /* In case of a bitmap page write error keep on looping over
140+ the tree to reclaim its memory through the free list instead of
141+ returning immediatelly. */
142+ if (UNIV_LIKELY(success)) {
143+ if (bmp_tree_node == last_bmp_tree_node) {
144+ mach_write_to_4(page
145+ + MODIFIED_PAGE_IS_LAST_BLOCK,
146+ 1);
147+ }
148+
149+ mach_write_ull(page + MODIFIED_PAGE_START_LSN,
150+ log_bmp_sys->start_lsn);
151+ mach_write_ull(page + MODIFIED_PAGE_END_LSN,
152+ log_bmp_sys->end_lsn);
153+ mach_write_to_4(page + MODIFIED_PAGE_BLOCK_CHECKSUM,
154+ log_online_calc_checksum(page));
155+
156+ success = log_online_write_bitmap_page(page);
157 }
158
159 bmp_tree_node->left = log_bmp_sys->page_free_list;
160@@ -1159,7 +1168,7 @@
161 }
162
163 rbt_reset(log_bmp_sys->modified_pages);
164- return TRUE;
165+ return success;
166 }
167
168 /*********************************************************************//**

Subscribers

People subscribed via source and target branches