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: no longer in the source branch.
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 (community) 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
=== added file 'Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_debug.result'
--- Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_debug.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_debug.result 2013-02-07 10:52:23 +0000
@@ -0,0 +1,23 @@
1DROP TABLE IF EXISTS t1;
2call mtr.add_suppression("InnoDB: Error: log tracking bitmap write failed, stopping log tracking thread!");
31st restart
4RESET CHANGED_PAGE_BITMAPS;
5CREATE TABLE t1 (x INT) ENGINE=InnoDB;
62nd restart
7INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
8INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
9INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
10INSERT INTO t1 SELECT x FROM t1;
11INSERT INTO t1 SELECT x FROM t1;
12INSERT INTO t1 SELECT x FROM t1;
13INSERT INTO t1 SELECT x FROM t1;
14INSERT INTO t1 SELECT x FROM t1;
15INSERT INTO t1 SELECT x FROM t1;
16INSERT INTO t1 SELECT x FROM t1;
17INSERT INTO t1 SELECT x FROM t1;
18INSERT INTO t1 SELECT x FROM t1;
19INSERT INTO t1 SELECT x FROM t1;
20INSERT INTO t1 SELECT x FROM t1;
21INSERT INTO t1 SELECT x FROM t1;
223rd restart
23DROP TABLE t1;
024
=== added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug-master.opt'
--- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug-master.opt 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug-master.opt 2013-02-07 10:52:23 +0000
@@ -0,0 +1,1 @@
1--innodb_track_changed_pages=TRUE --innodb_log_file_size=1M
02
=== added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug.test'
--- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_debug.test 2013-02-07 10:52:23 +0000
@@ -0,0 +1,56 @@
1#
2# Non-crash tests for the changed page bitmaps that require debug builds
3#
4--source include/have_debug.inc
5--source include/have_innodb_plugin.inc
6
7--disable_warnings
8DROP TABLE IF EXISTS t1;
9--enable_warnings
10
11let $MYSQLD_DATADIR= `select @@datadir`;
12
13call mtr.add_suppression("InnoDB: Error: log tracking bitmap write failed, stopping log tracking thread!");
14
15--echo 1st restart
16--source include/restart_mysqld.inc
17RESET CHANGED_PAGE_BITMAPS;
18CREATE TABLE t1 (x INT) ENGINE=InnoDB;
19
20#
21# Test for bug 1111226: test that bitmap write errors are handled gracefully
22#
23
24# Setup an error on bitmap write
25--echo 2nd restart
26--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
27--shutdown_server 10
28--source include/wait_until_disconnected.inc
29--enable_reconnect
30--exec echo "restart:-#d,bitmap_page_write_error" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
31--source include/wait_until_connected_again.inc
32
33# Generate log data that is larger than the log capacity
34INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
35INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
36INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
37INSERT INTO t1 SELECT x FROM t1;
38INSERT INTO t1 SELECT x FROM t1;
39INSERT INTO t1 SELECT x FROM t1;
40INSERT INTO t1 SELECT x FROM t1;
41INSERT INTO t1 SELECT x FROM t1;
42INSERT INTO t1 SELECT x FROM t1;
43INSERT INTO t1 SELECT x FROM t1;
44INSERT INTO t1 SELECT x FROM t1;
45INSERT INTO t1 SELECT x FROM t1;
46INSERT INTO t1 SELECT x FROM t1;
47INSERT INTO t1 SELECT x FROM t1;
48INSERT INTO t1 SELECT x FROM t1;
49
50# At this point the log tracker thread should have quit
51# TODO: test its status through I_S query once the table is implemented
52
53--echo 3rd restart
54--source include/restart_mysqld.inc
55
56DROP TABLE t1;
057
=== modified file 'Percona-Server/storage/innodb_plugin/log/log0online.c'
--- Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-07 05:14:23 +0000
+++ Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-07 10:52:23 +0000
@@ -1073,10 +1073,13 @@
10731073
1074 ut_ad(mutex_own(&log_bmp_sys->mutex));1074 ut_ad(mutex_own(&log_bmp_sys->mutex));
10751075
1076 /* Simulate a write error */
1077 DBUG_EXECUTE_IF("bitmap_page_write_error", return FALSE;);
1078
1076 success = os_file_write(log_bmp_sys->out.name, log_bmp_sys->out.file,1079 success = os_file_write(log_bmp_sys->out.name, log_bmp_sys->out.file,
1077 block,1080 block,
1078 (ulint)(log_bmp_sys->out.offset & 0xFFFFFFFF),1081 (ulint)(log_bmp_sys->out.offset & 0xFFFFFFFF),
1079 (ulint)(log_bmp_sys->out.offset << 32),1082 (ulint)(log_bmp_sys->out.offset >> 32),
1080 MODIFIED_PAGE_BLOCK_SIZE);1083 MODIFIED_PAGE_BLOCK_SIZE);
1081 if (UNIV_UNLIKELY(!success)) {1084 if (UNIV_UNLIKELY(!success)) {
10821085
@@ -1119,6 +1122,7 @@
1119{1122{
1120 ib_rbt_node_t *bmp_tree_node;1123 ib_rbt_node_t *bmp_tree_node;
1121 const ib_rbt_node_t *last_bmp_tree_node;1124 const ib_rbt_node_t *last_bmp_tree_node;
1125 ibool success = TRUE;
11221126
1123 ut_ad(mutex_own(&log_bmp_sys->mutex));1127 ut_ad(mutex_own(&log_bmp_sys->mutex));
11241128
@@ -1136,19 +1140,24 @@
11361140
1137 byte *page = rbt_value(byte, bmp_tree_node);1141 byte *page = rbt_value(byte, bmp_tree_node);
11381142
1139 if (bmp_tree_node == last_bmp_tree_node) {1143 /* In case of a bitmap page write error keep on looping over
1140 mach_write_to_4(page + MODIFIED_PAGE_IS_LAST_BLOCK, 1);1144 the tree to reclaim its memory through the free list instead of
1141 }1145 returning immediatelly. */
11421146 if (UNIV_LIKELY(success)) {
1143 mach_write_ull(page + MODIFIED_PAGE_START_LSN,1147 if (bmp_tree_node == last_bmp_tree_node) {
1144 log_bmp_sys->start_lsn);1148 mach_write_to_4(page
1145 mach_write_ull(page + MODIFIED_PAGE_END_LSN,1149 + MODIFIED_PAGE_IS_LAST_BLOCK,
1146 log_bmp_sys->end_lsn);1150 1);
1147 mach_write_to_4(page + MODIFIED_PAGE_BLOCK_CHECKSUM,1151 }
1148 log_online_calc_checksum(page));1152
11491153 mach_write_ull(page + MODIFIED_PAGE_START_LSN,
1150 if (!log_online_write_bitmap_page(page)) {1154 log_bmp_sys->start_lsn);
1151 return FALSE;1155 mach_write_ull(page + MODIFIED_PAGE_END_LSN,
1156 log_bmp_sys->end_lsn);
1157 mach_write_to_4(page + MODIFIED_PAGE_BLOCK_CHECKSUM,
1158 log_online_calc_checksum(page));
1159
1160 success = log_online_write_bitmap_page(page);
1152 }1161 }
11531162
1154 bmp_tree_node->left = log_bmp_sys->page_free_list;1163 bmp_tree_node->left = log_bmp_sys->page_free_list;
@@ -1159,7 +1168,7 @@
1159 }1168 }
11601169
1161 rbt_reset(log_bmp_sys->modified_pages);1170 rbt_reset(log_bmp_sys->modified_pages);
1162 return TRUE;1171 return success;
1163}1172}
11641173
1165/*********************************************************************//**1174/*********************************************************************//**

Subscribers

People subscribed via source and target branches