Merge lp:~gl-az/percona-server/port_ALL_O_DIRECT_to_5.6 into lp:percona-server/5.6

Proposed by George Ormond Lorch III
Status: Merged
Approved by: Laurynas Biveinis
Approved revision: no longer in the source branch.
Merged at revision: 433
Proposed branch: lp:~gl-az/percona-server/port_ALL_O_DIRECT_to_5.6
Merge into: lp:percona-server/5.6
Diff against target: 176 lines (+49/-12)
7 files modified
Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_flush.result (+6/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test (+16/-1)
Percona-Server/storage/innobase/fil/fil0fil.cc (+6/-4)
Percona-Server/storage/innobase/include/srv0srv.h (+5/-1)
Percona-Server/storage/innobase/log/log0log.cc (+9/-4)
Percona-Server/storage/innobase/os/os0file.cc (+4/-2)
Percona-Server/storage/innobase/srv/srv0start.cc (+3/-0)
To merge this branch: bzr merge lp:~gl-az/percona-server/port_ALL_O_DIRECT_to_5.6
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+187126@code.launchpad.net

Description of the change

Reviewed 5.5 ALL_O_DIRECT and fixes for 1131949. Ported a few lines of code and additional test from 5.5 track changed pages.

http://jenkins.percona.com/view/PS%205.6/job/percona-server-5.6-param/299/

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

    - 5.6 refactored fil_flush() and there is a new #define in
      fil0fil.cc fil_buffering_disabled() to check whether fsync() is
      disabled for a given tablespace. Since ALL_O_DIRECT disables
      fsync() for log tablespaces (see bug 1229583), it is probably a
      good idea to extend fil_buffering_disabled() to become aware of
      it too. This will have an effect of skipping some code paths
      such as unflushed_spaces list maintenance.
    - Consider adding ... || != SRV_UNIX_ALL_O_DIRECT check for
      fil_flush_file_spaces() call in log_checkpoint(). Without the
      previous fil_buffering_disabled() change,
      fil_flush_file_spaces() would still acquire the file system
      mutex, loop through file spaces, find the log ones, attempt to
      flush them with file system mutex acquired again, discovering it
      should be a no-op and returning. With the above change this is
      reduced to the initial mutex acquisition and loop through the
      spaces. And if we just skip fil_flush_file_spaces() call in
      log_checkpoint(), we avoid that too.
    - The new if statement in os_file_create_func() should be merged
      with the previous one to become else if.
    - Please remove the comment preceding that first if: "We disable
      OS caching (O_DIRECT) only on data files */
    - The SRV_UNIX_ALL_O_DIRECT comment in srv0srv.h could be
      replaced with something more descriptive along the lines of
      SRV_UNIX_O_DIRECT comment.
    - The "O_DSYNC means ... " comment in log_write_to() should
      become "O_DSYNC or ALL_O_DIRECT means ... "

review: Needs Fixing
Revision history for this message
George Ormond Lorch III (gl-az) wrote :
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

    - In fil_buffering_disabled, please explicitly check for purpose
      == FIL_LOG. This will future-proof the code a bit in the case
      a new tablespcae type is added.

review: Needs Fixing
Revision history for this message
George Ormond Lorch III (gl-az) wrote :

After IRC discussion and a bit of a revelation in ALL_O_DIRECT/fsync behavior, changed comment on ALL_O_DIRECT to correctly reflect actual behavior and changed fil_buffering_disabled() to test (s)->purpose == FIL_LOG.

Jenkins run on raw 5.6 rev 430 (trunk) to see what is actually currently failing http://jenkins.percona.com/view/PS%205.6/job/percona-server-5.6-param/308

JEnkins run on merged feature and fixes http://jenkins.percona.com/view/PS%205.6/job/percona-server-5.6-param/311

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_flush.result'
2--- Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_flush.result 2013-05-09 19:43:37 +0000
3+++ Percona-Server/mysql-test/suite/innodb/r/percona_changed_page_bmp_flush.result 2013-09-26 04:59:04 +0000
4@@ -17,5 +17,11 @@
5 ib_modified_log_2
6 ib_modified_log_3
7 ib_modified_log_4
8+INSERT INTO t1 VALUES (4, REPEAT("e", 20000));
9+ib_modified_log_1
10+ib_modified_log_2
11+ib_modified_log_3
12+ib_modified_log_4
13+ib_modified_log_5
14 RESET CHANGED_PAGE_BITMAPS;
15 DROP TABLE t1;
16
17=== modified file 'Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test'
18--- Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test 2013-05-27 17:45:26 +0000
19+++ Percona-Server/mysql-test/suite/innodb/t/percona_changed_page_bmp_flush.test 2013-09-26 04:59:04 +0000
20@@ -63,6 +63,21 @@
21
22 INSERT INTO t1 VALUES (3, REPEAT("c", 20000));
23
24+# Test innodb_flush_method=ALL_O_DIRECT
25+# Check that the previous test produced bitmap data while the server is down.
26+#
27+--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
28+--shutdown_server 10
29+--source include/wait_until_disconnected.inc
30+file_exists $BITMAP_FILE;
31+--replace_regex /_[[:digit:]]+\.xdb$//
32+list_files $MYSQLD_DATADIR ib_modified_log*;
33+--enable_reconnect
34+--exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=ALL_O_DIRECT" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
35+--source include/wait_until_connected_again.inc
36+
37+INSERT INTO t1 VALUES (4, REPEAT("d", 20000));
38+
39 #
40 # Test innodb_flush_method=O_DIRECT_NO_FSYNC
41 # Check that the previous test produced bitmap data while the server is down.
42@@ -77,7 +92,7 @@
43 --exec echo "restart:--innodb-track-changed-pages=1 --innodb-flush-method=O_DIRECT_NO_FSYNC" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
44 --source include/wait_until_connected_again.inc
45
46-INSERT INTO t1 VALUES (4, REPEAT("d", 20000));
47+INSERT INTO t1 VALUES (4, REPEAT("e", 20000));
48
49 #
50 # Restart the server with default options
51
52=== modified file 'Percona-Server/storage/innobase/fil/fil0fil.cc'
53--- Percona-Server/storage/innobase/fil/fil0fil.cc 2013-09-09 14:20:25 +0000
54+++ Percona-Server/storage/innobase/fil/fil0fil.cc 2013-09-26 04:59:04 +0000
55@@ -321,10 +321,12 @@
56
57 /** Determine if user has explicitly disabled fsync(). */
58 #ifndef __WIN__
59-# define fil_buffering_disabled(s) \
60- ((s)->purpose == FIL_TABLESPACE \
61- && srv_unix_file_flush_method \
62- == SRV_UNIX_O_DIRECT_NO_FSYNC)
63+# define fil_buffering_disabled(s) \
64+ (((s)->purpose == FIL_TABLESPACE \
65+ && srv_unix_file_flush_method == SRV_UNIX_O_DIRECT_NO_FSYNC)\
66+ || ((s)->purpose == FIL_LOG \
67+ && srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT))
68+
69 #else /* __WIN__ */
70 # define fil_buffering_disabled(s) (0)
71 #endif /* __WIN__ */
72
73=== modified file 'Percona-Server/storage/innobase/include/srv0srv.h'
74--- Percona-Server/storage/innobase/include/srv0srv.h 2013-08-06 15:16:34 +0000
75+++ Percona-Server/storage/innobase/include/srv0srv.h 2013-09-26 04:59:04 +0000
76@@ -557,13 +557,17 @@
77 the reason for which is that some FS
78 do not flush meta-data when
79 unbuffered IO happens */
80- SRV_UNIX_O_DIRECT_NO_FSYNC
81+ SRV_UNIX_O_DIRECT_NO_FSYNC,
82 /*!< do not use fsync() when using
83 direct IO i.e.: it can be set to avoid
84 the fsync() call that we make when
85 using SRV_UNIX_O_DIRECT. However, in
86 this case user/DBA should be sure about
87 the integrity of the meta-data */
88+ SRV_UNIX_ALL_O_DIRECT /*!< similar to O_DIRECT, invokes
89+ os_file_set_nocache() on data and log files.
90+ This implies using non-buffered IO but still
91+ using fsync for data but not log files. */
92 };
93
94 /** Alternatives for file i/o in Windows */
95
96=== modified file 'Percona-Server/storage/innobase/log/log0log.cc'
97--- Percona-Server/storage/innobase/log/log0log.cc 2013-06-25 13:13:06 +0000
98+++ Percona-Server/storage/innobase/log/log0log.cc 2013-09-26 04:59:04 +0000
99@@ -1154,6 +1154,7 @@
100 group = (log_group_t*)((ulint) group - 1);
101
102 if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
103+ && srv_unix_file_flush_method != SRV_UNIX_ALL_O_DIRECT
104 && srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
105
106 fil_flush(group->space_id);
107@@ -1175,6 +1176,7 @@
108 logs and cannot end up here! */
109
110 if (srv_unix_file_flush_method != SRV_UNIX_O_DSYNC
111+ && srv_unix_file_flush_method != SRV_UNIX_ALL_O_DIRECT
112 && srv_unix_file_flush_method != SRV_UNIX_NOSYNC
113 && thd_flush_log_at_trx_commit(NULL) != 2) {
114
115@@ -1574,9 +1576,11 @@
116
117 mutex_exit(&(log_sys->mutex));
118
119- if (srv_unix_file_flush_method == SRV_UNIX_O_DSYNC) {
120- /* O_DSYNC means the OS did not buffer the log file at all:
121- so we have also flushed to disk what we have written */
122+ if (srv_unix_file_flush_method == SRV_UNIX_O_DSYNC
123+ || srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT) {
124+ /* O_DSYNC or ALL_O_DIRECT means the OS did not buffer the log
125+ file at all: so we have also flushed to disk what we have
126+ written */
127
128 log_sys->flushed_to_disk_lsn = log_sys->write_lsn;
129
130@@ -2059,7 +2063,8 @@
131 recv_apply_hashed_log_recs(TRUE);
132 }
133
134- if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC) {
135+ if (srv_unix_file_flush_method != SRV_UNIX_NOSYNC &&
136+ srv_unix_file_flush_method != SRV_UNIX_ALL_O_DIRECT) {
137 fil_flush_file_spaces(FIL_TABLESPACE);
138 }
139
140
141=== modified file 'Percona-Server/storage/innobase/os/os0file.cc'
142--- Percona-Server/storage/innobase/os/os0file.cc 2013-08-29 17:46:30 +0000
143+++ Percona-Server/storage/innobase/os/os0file.cc 2013-09-26 04:59:04 +0000
144@@ -1790,8 +1790,6 @@
145
146 } while (retry);
147
148- /* We disable OS caching (O_DIRECT) only on data files */
149-
150 if (!srv_read_only_mode
151 && *success
152 && type != OS_LOG_FILE
153@@ -1799,6 +1797,10 @@
154 || srv_unix_file_flush_method == SRV_UNIX_O_DIRECT_NO_FSYNC)) {
155
156 os_file_set_nocache(file, name, mode_str);
157+ } else if (!srv_read_only_mode
158+ && *success
159+ && srv_unix_file_flush_method == SRV_UNIX_ALL_O_DIRECT) {
160+ os_file_set_nocache(file, name, mode_str);
161 }
162
163 #ifdef USE_FILE_LOCK
164
165=== modified file 'Percona-Server/storage/innobase/srv/srv0start.cc'
166--- Percona-Server/storage/innobase/srv/srv0start.cc 2013-08-14 03:57:21 +0000
167+++ Percona-Server/storage/innobase/srv/srv0start.cc 2013-09-26 04:59:04 +0000
168@@ -1703,6 +1703,9 @@
169 } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT")) {
170 srv_unix_file_flush_method = SRV_UNIX_O_DIRECT;
171
172+ } else if (0 == ut_strcmp(srv_file_flush_method_str, "ALL_O_DIRECT")) {
173+ srv_unix_file_flush_method = SRV_UNIX_ALL_O_DIRECT;
174+
175 } else if (0 == ut_strcmp(srv_file_flush_method_str, "O_DIRECT_NO_FSYNC")) {
176 srv_unix_file_flush_method = SRV_UNIX_O_DIRECT_NO_FSYNC;
177

Subscribers

People subscribed via source and target branches