Merge lp:~laurynas-biveinis/percona-server/bug1105709-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: 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
George Ormond Lorch III g2 Approve
Review via email: mp+145798@code.launchpad.net
To post a comment you must log in.
Revision history for this message
George Ormond Lorch III (gl-az) wrote :

Minor comment spelling on diff line 161 /shoul/should

review: Approve (g2)
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Will fix, thanks.

Revision history for this message
Stewart Smith (stewart) :
review: Approve
521. By Laurynas Biveinis

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.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

Fixed.

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_flush.result'
--- Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_flush.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb_plugin/r/percona_changed_page_bmp_flush.result 2013-02-06 09:06:26 +0000
@@ -0,0 +1,19 @@
1DROP TABLE IF EXISTS t1;
2RESET CHANGED_PAGE_BITMAPS;
3CREATE TABLE t1 (a INT, b BLOB) ENGINE=InnoDB;
4INSERT INTO t1 VALUES (1, REPEAT("a", 20000));
5ib_modified_log_1
6INSERT INTO t1 VALUES (2, REPEAT("b", 20000));
7ib_modified_log_1
8ib_modified_log_2
9INSERT INTO t1 VALUES (3, REPEAT("c", 20000));
10ib_modified_log_1
11ib_modified_log_2
12ib_modified_log_3
13INSERT INTO t1 VALUES (4, REPEAT("d", 20000));
14ib_modified_log_1
15ib_modified_log_2
16ib_modified_log_3
17ib_modified_log_4
18RESET CHANGED_PAGE_BITMAPS;
19DROP TABLE t1;
020
=== added file 'Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_flush.test'
--- Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_flush.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb_plugin/t/percona_changed_page_bmp_flush.test 2013-02-06 09:06:26 +0000
@@ -0,0 +1,93 @@
1#
2# Test the interaction between innodb_flush_method and bitmap file writes
3#
4--source include/not_windows.inc
5--source include/have_innodb_plugin.inc
6
7let $MYSQLD_DATADIR= `select @@datadir`;
8let $BITMAP_FILE= $MYSQLD_DATADIR/ib_modified_log_1_0.xdb;
9
10--disable_warnings
11DROP TABLE IF EXISTS t1;
12--enable_warnings
13
14RESET CHANGED_PAGE_BITMAPS;
15
16CREATE TABLE t1 (a INT, b BLOB) ENGINE=InnoDB;
17
18#
19# Test innodb_flush_method=fdatasync (the default)
20#
21--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
22--shutdown_server 10
23--source include/wait_until_disconnected.inc
24--enable_reconnect
25--exec echo "restart:--innodb-track-changed-pages=1" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
26--source include/wait_until_connected_again.inc
27
28INSERT INTO t1 VALUES (1, REPEAT("a", 20000));
29
30#
31# Test innodb_flush_method=O_DSYNC
32# Check that the previous test produced bitmap data while the server is down.
33#
34--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
35--shutdown_server 10
36--source include/wait_until_disconnected.inc
37file_exists $BITMAP_FILE;
38# Here and below remove the LSNs from the file names on listing them
39--replace_regex /_[[:digit:]]+\.xdb$//
40list_files $MYSQLD_DATADIR ib_modified_log*;
41--enable_reconnect
42--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DSYNC" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
43--source include/wait_until_connected_again.inc
44
45INSERT INTO t1 VALUES (2, REPEAT("b", 20000));
46
47#
48# Test innodb_flush_method=O_DIRECT
49# Check that the previous test produced bitmap data while the server is down.
50#
51--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
52--shutdown_server 10
53--source include/wait_until_disconnected.inc
54file_exists $BITMAP_FILE;
55--replace_regex /_[[:digit:]]+\.xdb$//
56list_files $MYSQLD_DATADIR ib_modified_log*;
57--enable_reconnect
58--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DIRECT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
59--source include/wait_until_connected_again.inc
60
61INSERT INTO t1 VALUES (3, REPEAT("c", 20000));
62
63#
64# Test innodb_flush_method=O_DIRECT
65# Check that the previous test produced bitmap data while the server is down.
66#
67--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
68--shutdown_server 10
69--source include/wait_until_disconnected.inc
70file_exists $BITMAP_FILE;
71--replace_regex /_[[:digit:]]+\.xdb$//
72list_files $MYSQLD_DATADIR ib_modified_log*;
73--enable_reconnect
74--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DIRECT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
75--source include/wait_until_connected_again.inc
76
77INSERT INTO t1 VALUES (4, REPEAT("d", 20000));
78
79#
80# Restart the server with default options
81#
82--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
83--shutdown_server 10
84--source include/wait_until_disconnected.inc
85file_exists $BITMAP_FILE;
86--replace_regex /_[[:digit:]]+\.xdb$//
87list_files $MYSQLD_DATADIR ib_modified_log*;
88--enable_reconnect
89--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
90--source include/wait_until_connected_again.inc
91
92RESET CHANGED_PAGE_BITMAPS;
93DROP TABLE t1;
094
=== modified file 'Percona-Server/storage/innodb_plugin/log/log0online.c'
--- Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-06 09:06:26 +0000
+++ Percona-Server/storage/innodb_plugin/log/log0online.c 2013-02-06 09:06:26 +0000
@@ -491,6 +491,23 @@
491}491}
492492
493/*********************************************************************//**493/*********************************************************************//**
494Check if an old file that has the name of a new bitmap file we are about to
495create should be overwritten. */
496static
497ibool
498log_online_should_overwrite(
499/*========================*/
500 const char *path) /*!< in: path to file */
501{
502 ibool success;
503 os_file_stat_t file_info;
504
505 /* Currently, it's OK to overwrite 0-sized files only */
506 success = os_file_get_status(path, &file_info);
507 return success && file_info.size == 0LL;
508}
509
510/*********************************************************************//**
494Create a new empty bitmap output file.511Create a new empty bitmap output file.
495512
496@return TRUE if operation succeeded, FALSE if I/O error */513@return TRUE if operation succeeded, FALSE if I/O error */
@@ -499,11 +516,21 @@
499log_online_start_bitmap_file(void)516log_online_start_bitmap_file(void)
500/*==============================*/517/*==============================*/
501{518{
502 ibool success;519 ibool success = TRUE;
503520
504 log_bmp_sys->out.file521 /* Check for an old file that should be deleted first */
505 = os_file_create(log_bmp_sys->out.name, OS_FILE_OVERWRITE,522 if (log_online_should_overwrite(log_bmp_sys->out.name)) {
506 OS_FILE_NORMAL, OS_DATA_FILE, &success);523 success = os_file_delete(log_bmp_sys->out.name);
524 }
525
526 if (UNIV_LIKELY(success)) {
527 log_bmp_sys->out.file
528 = os_file_create_simple_no_error_handling(
529 log_bmp_sys->out.name,
530 OS_FILE_CREATE,
531 OS_FILE_READ_WRITE,
532 &success);
533 }
507 if (UNIV_UNLIKELY(!success)) {534 if (UNIV_UNLIKELY(!success)) {
508535
509 /* The following call prints an error message */536 /* The following call prints an error message */
@@ -1071,6 +1098,11 @@
1071 return FALSE;1098 return FALSE;
1072 }1099 }
10731100
1101#ifdef UNIV_LINUX
1102 posix_fadvise(log_bmp_sys->out.file, log_bmp_sys->out.offset,
1103 MODIFIED_PAGE_BLOCK_SIZE, POSIX_FADV_DONTNEED);
1104#endif
1105
1074 log_bmp_sys->out.offset += MODIFIED_PAGE_BLOCK_SIZE;1106 log_bmp_sys->out.offset += MODIFIED_PAGE_BLOCK_SIZE;
1075 return TRUE;1107 return TRUE;
1076}1108}

Subscribers

People subscribed via source and target branches