Merge lp:~laurynas-biveinis/percona-server/bug1105709-5.1 into lp:percona-server/5.1

Proposed by Laurynas Biveinis on 2013-01-31
Status: Merged
Approved by: Stewart Smith on 2013-02-06
Approved revision: no longer in the source branch.
Merged at revision: 526
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1105709-5.1
Merge into: lp:percona-server/5.1
Prerequisite: lp:~laurynas-biveinis/percona-server/BT-16274-bug1083669-5.1
Diff against target: 188 lines (+149/-5)
3 files modified
Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_flush.result (+19/-0)
Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_flush.test (+93/-0)
Percona-Server/storage/innodb_plugin/log/log0online.c (+37/-5)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1105709-5.1
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve on 2013-02-06
George Ormond Lorch III g2 2013-01-31 Approve on 2013-02-05
Review via email: mp+145798@code.launchpad.net
To post a comment you must log in.
George Ormond Lorch III (gl-az) wrote :

Minor comment spelling on diff line 161 /shoul/should

review: Approve (g2)

Will fix, thanks.

Stewart Smith (stewart) :
review: Approve
521. By Laurynas Biveinis on 2013-02-06

Fix

- bug 1105709 (InnoDB: Error: Write to file ./ib_modified_log_1_0.xdb
  failed at offset 0 0. when O_DIRECT is used in combination with
  innodb_track_changed_pages=1) and
- bug 1111144 (Newly created bitmap files should indiscriminately
  overwrite old ones).

The issue with bug 1105709 is that bitmap files were created with a
os_file_create(..., OS_DATA_FILE, ...) call, that makes it to be
treated as an InnoDB data file for flushing purposes. Thus,
innodb_flush_method=O_DIRECT made the bitmap files to be created with
O_DIRECT too, and they were not ready for such operation nor it was
intended to.

The fix is to switch to os_file_create_simple API that makes
innodb_flush_method stop applying to the bitmap files. For best OS
cache effects, indicate that we are not going to read the newly
written bitmap data by a posix_fadvise() call.

Add a testcase percona_changed_page_bmp_flush that tests the
combination of bitmap tracking with all the InnoDB flushing methods.

The issue with bug 1111144 is that the os_file_create() above
specified OS_FILE_OVERWRITE too, thus any new bitmap files would
silently overwrite any existing files with the same name. The switch
to os_file_create_simple() made the file create fail in the case of
existing file. A special case is a zero-sized existing files, which
are part of a regular operation, and they are deleted before creating
a new file.

Fixed.

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_flush.result'
2--- Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_flush.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_flush.result 2013-02-06 09:06:26 +0000
4@@ -0,0 +1,19 @@
5+DROP TABLE IF EXISTS t1;
6+RESET CHANGED_PAGE_BITMAPS;
7+CREATE TABLE t1 (a INT, b BLOB) ENGINE=InnoDB;
8+INSERT INTO t1 VALUES (1, REPEAT("a", 20000));
9+ib_modified_log_1
10+INSERT INTO t1 VALUES (2, REPEAT("b", 20000));
11+ib_modified_log_1
12+ib_modified_log_2
13+INSERT INTO t1 VALUES (3, REPEAT("c", 20000));
14+ib_modified_log_1
15+ib_modified_log_2
16+ib_modified_log_3
17+INSERT INTO t1 VALUES (4, REPEAT("d", 20000));
18+ib_modified_log_1
19+ib_modified_log_2
20+ib_modified_log_3
21+ib_modified_log_4
22+RESET CHANGED_PAGE_BITMAPS;
23+DROP TABLE t1;
24
25=== added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_flush.test'
26--- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_flush.test 1970-01-01 00:00:00 +0000
27+++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_flush.test 2013-02-06 09:06:26 +0000
28@@ -0,0 +1,93 @@
29+#
30+# Test the interaction between innodb_flush_method and bitmap file writes
31+#
32+--source include/not_windows.inc
33+--source include/have_innodb_plugin.inc
34+
35+let $MYSQLD_DATADIR= `select @@datadir`;
36+let $BITMAP_FILE= $MYSQLD_DATADIR/ib_modified_log_1_0.xdb;
37+
38+--disable_warnings
39+DROP TABLE IF EXISTS t1;
40+--enable_warnings
41+
42+RESET CHANGED_PAGE_BITMAPS;
43+
44+CREATE TABLE t1 (a INT, b BLOB) ENGINE=InnoDB;
45+
46+#
47+# Test innodb_flush_method=fdatasync (the default)
48+#
49+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
50+--shutdown_server 10
51+--source include/wait_until_disconnected.inc
52+--enable_reconnect
53+--exec echo "restart:--innodb-track-changed-pages=1" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
54+--source include/wait_until_connected_again.inc
55+
56+INSERT INTO t1 VALUES (1, REPEAT("a", 20000));
57+
58+#
59+# Test innodb_flush_method=O_DSYNC
60+# Check that the previous test produced bitmap data while the server is down.
61+#
62+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
63+--shutdown_server 10
64+--source include/wait_until_disconnected.inc
65+file_exists $BITMAP_FILE;
66+# Here and below remove the LSNs from the file names on listing them
67+--replace_regex /_[[:digit:]]+\.xdb$//
68+list_files $MYSQLD_DATADIR ib_modified_log*;
69+--enable_reconnect
70+--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DSYNC" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
71+--source include/wait_until_connected_again.inc
72+
73+INSERT INTO t1 VALUES (2, REPEAT("b", 20000));
74+
75+#
76+# Test innodb_flush_method=O_DIRECT
77+# Check that the previous test produced bitmap data while the server is down.
78+#
79+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
80+--shutdown_server 10
81+--source include/wait_until_disconnected.inc
82+file_exists $BITMAP_FILE;
83+--replace_regex /_[[:digit:]]+\.xdb$//
84+list_files $MYSQLD_DATADIR ib_modified_log*;
85+--enable_reconnect
86+--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DIRECT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
87+--source include/wait_until_connected_again.inc
88+
89+INSERT INTO t1 VALUES (3, REPEAT("c", 20000));
90+
91+#
92+# Test innodb_flush_method=O_DIRECT
93+# Check that the previous test produced bitmap data while the server is down.
94+#
95+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
96+--shutdown_server 10
97+--source include/wait_until_disconnected.inc
98+file_exists $BITMAP_FILE;
99+--replace_regex /_[[:digit:]]+\.xdb$//
100+list_files $MYSQLD_DATADIR ib_modified_log*;
101+--enable_reconnect
102+--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DIRECT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
103+--source include/wait_until_connected_again.inc
104+
105+INSERT INTO t1 VALUES (4, REPEAT("d", 20000));
106+
107+#
108+# Restart the server with default options
109+#
110+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
111+--shutdown_server 10
112+--source include/wait_until_disconnected.inc
113+file_exists $BITMAP_FILE;
114+--replace_regex /_[[:digit:]]+\.xdb$//
115+list_files $MYSQLD_DATADIR ib_modified_log*;
116+--enable_reconnect
117+--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
118+--source include/wait_until_connected_again.inc
119+
120+RESET CHANGED_PAGE_BITMAPS;
121+DROP TABLE t1;
122
123=== modified file 'Percona-Server/storage/innodb_plugin/log/log0online.c'
124--- Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-06 09:06:26 +0000
125+++ Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-06 09:06:26 +0000
126@@ -491,6 +491,23 @@
127 }
128
129 /*********************************************************************//**
130+Check if an old file that has the name of a new bitmap file we are about to
131+create should be overwritten. */
132+static
133+ibool
134+log_online_should_overwrite(
135+/*========================*/
136+ const char *path) /*!< in: path to file */
137+{
138+ ibool success;
139+ os_file_stat_t file_info;
140+
141+ /* Currently, it's OK to overwrite 0-sized files only */
142+ success = os_file_get_status(path, &file_info);
143+ return success && file_info.size == 0LL;
144+}
145+
146+/*********************************************************************//**
147 Create a new empty bitmap output file.
148
149 @return TRUE if operation succeeded, FALSE if I/O error */
150@@ -499,11 +516,21 @@
151 log_online_start_bitmap_file(void)
152 /*==============================*/
153 {
154- ibool success;
155-
156- log_bmp_sys->out.file
157- = os_file_create(log_bmp_sys->out.name, OS_FILE_OVERWRITE,
158- OS_FILE_NORMAL, OS_DATA_FILE, &success);
159+ ibool success = TRUE;
160+
161+ /* Check for an old file that should be deleted first */
162+ if (log_online_should_overwrite(log_bmp_sys->out.name)) {
163+ success = os_file_delete(log_bmp_sys->out.name);
164+ }
165+
166+ if (UNIV_LIKELY(success)) {
167+ log_bmp_sys->out.file
168+ = os_file_create_simple_no_error_handling(
169+ log_bmp_sys->out.name,
170+ OS_FILE_CREATE,
171+ OS_FILE_READ_WRITE,
172+ &success);
173+ }
174 if (UNIV_UNLIKELY(!success)) {
175
176 /* The following call prints an error message */
177@@ -1071,6 +1098,11 @@
178 return FALSE;
179 }
180
181+#ifdef UNIV_LINUX
182+ posix_fadvise(log_bmp_sys->out.file, log_bmp_sys->out.offset,
183+ MODIFIED_PAGE_BLOCK_SIZE, POSIX_FADV_DONTNEED);
184+#endif
185+
186 log_bmp_sys->out.offset += MODIFIED_PAGE_BLOCK_SIZE;
187 return TRUE;
188 }

Subscribers

People subscribed via source and target branches