Merge lp:~laurynas-biveinis/percona-server/xtradb-preflush-backoff into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Sergei Glushchenko
Approved revision: no longer in the source branch.
Merged at revision: 454
Proposed branch: lp:~laurynas-biveinis/percona-server/xtradb-preflush-backoff
Merge into: lp:percona-server/5.6
Diff against target: 238 lines (+136/-17)
7 files modified
Percona-Server/mysql-test/suite/sys_vars/r/innodb_foreground_preflush_basic.result (+23/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_foreground_preflush_basic.test (+30/-0)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+25/-0)
Percona-Server/storage/innobase/include/buf0types.h (+11/-0)
Percona-Server/storage/innobase/include/srv0srv.h (+2/-0)
Percona-Server/storage/innobase/log/log0log.cc (+41/-17)
Percona-Server/storage/innobase/srv/srv0srv.cc (+4/-0)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/xtradb-preflush-backoff
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 Approve
Vadim Tkachenko Approve
Review via email: mp+189086@code.launchpad.net

Description of the change

http://jenkins.percona.com/job/percona-server-5.6-param/343/

Implement query thread waits at the sync preflush point, blueprint
https://blueprints.launchpad.net/percona-server/+spec/xtradb-preflush-backoff.

Whenever a query thread needs to perform a sync preflush to proceed,
two options are now available:
1) as previously, the query thread may issue a flush list batch itself
and wait for it to complete. This is also used whenever the page
cleaner thread is not running.
2) alternatively the query thread may wait until the flush list flush
is performed by the page cleaner thread. The wait is implemented by
maintaining a wait iteration counter, and a random duration sleep of up
to two to power of loop counter value is performed. To prevent
runaway sleeps, the counter is reset every 16 iterations.

The behavior is controlled by a new system variable
innodb_foreground_preflush with two possible values "sync_preflush"
and "exponential_backoff". Add a sys_vars test for this variable.

To post a comment you must log in.
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

LGTM

review: Approve
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Approve

review: Approve (g2)

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/sys_vars/r/innodb_foreground_preflush_basic.result'
2--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_foreground_preflush_basic.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_foreground_preflush_basic.result 2013-10-03 13:54:00 +0000
4@@ -0,0 +1,23 @@
5+SET @start_value = @@GLOBAL.innodb_foreground_preflush;
6+SELECT @@GLOBAL.innodb_foreground_preflush;
7+@@GLOBAL.innodb_foreground_preflush
8+exponential_backoff
9+SELECT @@SESSION.innodb_foreground_preflush;
10+ERROR HY000: Variable 'innodb_foreground_preflush' is a GLOBAL variable
11+SET GLOBAL innodb_foreground_preflush='sync_preflush';
12+SELECT @@GLOBAL.innodb_foreground_preflush;
13+@@GLOBAL.innodb_foreground_preflush
14+sync_preflush
15+SET GLOBAL innodb_foreground_preflush='exponential_backoff';
16+SELECT @@GLOBAL.innodb_foreground_preflush;
17+@@GLOBAL.innodb_foreground_preflush
18+exponential_backoff
19+SET GLOBAL innodb_foreground_preflush=1.1;
20+ERROR 42000: Incorrect argument type to variable 'innodb_foreground_preflush'
21+SET GLOBAL innodb_foreground_preflush=1e1;
22+ERROR 42000: Incorrect argument type to variable 'innodb_foreground_preflush'
23+SET GLOBAL innodb_foreground_preflush=2;
24+ERROR 42000: Variable 'innodb_foreground_preflush' can't be set to the value of '2'
25+SET GLOBAL innodb_foreground_preflush='foo';
26+ERROR 42000: Variable 'innodb_foreground_preflush' can't be set to the value of 'foo'
27+SET GLOBAL innodb_foreground_preflush = @start_value;
28
29=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_foreground_preflush_basic.test'
30--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_foreground_preflush_basic.test 1970-01-01 00:00:00 +0000
31+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_foreground_preflush_basic.test 2013-10-03 13:54:00 +0000
32@@ -0,0 +1,30 @@
33+--source include/have_innodb.inc
34+
35+# A dynamic, global variable
36+
37+SET @start_value = @@GLOBAL.innodb_foreground_preflush;
38+
39+# Default value
40+SELECT @@GLOBAL.innodb_foreground_preflush;
41+
42+# Global only
43+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
44+SELECT @@SESSION.innodb_foreground_preflush;
45+
46+# Correct values
47+SET GLOBAL innodb_foreground_preflush='sync_preflush';
48+SELECT @@GLOBAL.innodb_foreground_preflush;
49+SET GLOBAL innodb_foreground_preflush='exponential_backoff';
50+SELECT @@GLOBAL.innodb_foreground_preflush;
51+
52+# Incorrect values
53+--error ER_WRONG_TYPE_FOR_VAR
54+SET GLOBAL innodb_foreground_preflush=1.1;
55+--error ER_WRONG_TYPE_FOR_VAR
56+SET GLOBAL innodb_foreground_preflush=1e1;
57+--error ER_WRONG_VALUE_FOR_VAR
58+SET GLOBAL innodb_foreground_preflush=2;
59+--error ER_WRONG_VALUE_FOR_VAR
60+SET GLOBAL innodb_foreground_preflush='foo';
61+
62+SET GLOBAL innodb_foreground_preflush = @start_value;
63
64=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
65--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-10-03 10:03:41 +0000
66+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-10-03 13:54:00 +0000
67@@ -250,6 +250,21 @@
68 NULL
69 };
70
71+/** Possible values for system variable "innodb_foreground_preflush". */
72+static const char* innodb_foreground_preflush_names[] = {
73+ "sync_preflush",
74+ "exponential_backoff",
75+ NullS
76+};
77+
78+/* Enumeration for innodb_foreground_preflush. */
79+static TYPELIB innodb_foreground_preflush_typelib = {
80+ array_elements(innodb_foreground_preflush_names) - 1,
81+ "innodb_foreground_preflush_typelib",
82+ innodb_foreground_preflush_names,
83+ NULL
84+};
85+
86 /* The following counter is used to convey information to InnoDB
87 about server activity: in selects it is not sensible to call
88 srv_active_wake_master_thread after each fetch or search, we only do
89@@ -16720,6 +16735,15 @@
90 "established by the buffer pool memory region. Disabled by default.",
91 NULL, NULL, FALSE);
92
93+static MYSQL_SYSVAR_ENUM(foreground_preflush, srv_foreground_preflush,
94+ PLUGIN_VAR_OPCMDARG,
95+ "The algorithm InnoDB uses for the query threads at sync preflush. "
96+ "Possible values are "
97+ "SYNC_PREFLUSH: perform a sync preflush as Oracle MySQL; "
98+ "EXPONENTIAL_BACKOFF: (default) wait for the page cleaner flush.",
99+ NULL, NULL, SRV_FOREGROUND_PREFLUSH_EXP_BACKOFF,
100+ &innodb_foreground_preflush_typelib);
101+
102 #ifdef UNIV_LINUX
103
104 static MYSQL_SYSVAR_ULONG(sched_priority_cleaner, srv_sched_priority_cleaner,
105@@ -17505,6 +17529,7 @@
106 MYSQL_SYSVAR(cleaner_eviction_factor),
107 #endif /* defined UNIV_DEBUG || defined UNIV_PERF_DEBUG */
108 MYSQL_SYSVAR(cleaner_lsn_age_factor),
109+ MYSQL_SYSVAR(foreground_preflush),
110 MYSQL_SYSVAR(print_all_deadlocks),
111 MYSQL_SYSVAR(cmp_per_index_enabled),
112 MYSQL_SYSVAR(undo_logs),
113
114=== modified file 'Percona-Server/storage/innobase/include/buf0types.h'
115--- Percona-Server/storage/innobase/include/buf0types.h 2013-10-03 07:45:17 +0000
116+++ Percona-Server/storage/innobase/include/buf0types.h 2013-10-03 13:54:00 +0000
117@@ -107,6 +107,17 @@
118 checkpoint age higher. */
119 };
120
121+/** Alternatives for srv_foreground_preflush, set through
122+innodb_foreground_preflush variable */
123+enum srv_foreground_preflush_t {
124+ SRV_FOREGROUND_PREFLUSH_SYNC_PREFLUSH, /*!< Original Oracle MySQL 5.6
125+ behavior of performing a sync
126+ flush list flush */
127+ SRV_FOREGROUND_PREFLUSH_EXP_BACKOFF /*!< Exponential backoff wait
128+ for the page cleaner to flush
129+ for us */
130+};
131+
132 /** Parameters of binary buddy system for compressed pages (buf0buddy.h) */
133 /* @{ */
134 /** Zip shift value for the smallest page size */
135
136=== modified file 'Percona-Server/storage/innobase/include/srv0srv.h'
137--- Percona-Server/storage/innobase/include/srv0srv.h 2013-10-03 10:03:41 +0000
138+++ Percona-Server/storage/innobase/include/srv0srv.h 2013-10-03 13:54:00 +0000
139@@ -309,6 +309,8 @@
140 extern ulint srv_mem_pool_size;
141 extern ulint srv_lock_table_size;
142
143+extern ulint srv_foreground_preflush;/*!< Query thread preflush algorithm */
144+
145 extern ulint srv_cleaner_max_lru_time;/*!< the maximum time limit for a
146 single LRU tail flush iteration by the
147 page cleaner thread */
148
149=== modified file 'Percona-Server/storage/innobase/log/log0log.cc'
150--- Percona-Server/storage/innobase/log/log0log.cc 2013-09-26 04:57:55 +0000
151+++ Percona-Server/storage/innobase/log/log0log.cc 2013-10-03 13:54:00 +0000
152@@ -1716,8 +1716,8 @@
153 lsn_t new_oldest) /*!< in: try to advance oldest_modified_lsn
154 at least to this lsn */
155 {
156- bool success;
157- ulint n_pages;
158+ lsn_t current_oldest;
159+ ulint i;
160
161 if (recv_recovery_on) {
162 /* If the recovery is running, we must first apply all
163@@ -1732,21 +1732,45 @@
164 recv_apply_hashed_log_recs(TRUE);
165 }
166
167- success = buf_flush_list(ULINT_MAX, new_oldest, &n_pages);
168-
169- buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
170-
171- if (!success) {
172- MONITOR_INC(MONITOR_FLUSH_SYNC_WAITS);
173- }
174-
175- MONITOR_INC_VALUE_CUMULATIVE(
176- MONITOR_FLUSH_SYNC_TOTAL_PAGE,
177- MONITOR_FLUSH_SYNC_COUNT,
178- MONITOR_FLUSH_SYNC_PAGES,
179- n_pages);
180-
181- return(success);
182+ if (!buf_page_cleaner_is_active
183+ || (srv_foreground_preflush
184+ == SRV_FOREGROUND_PREFLUSH_SYNC_PREFLUSH)) {
185+
186+ ulint n_pages;
187+
188+ bool success = buf_flush_list(ULINT_MAX, new_oldest, &n_pages);
189+
190+ buf_flush_wait_batch_end(NULL, BUF_FLUSH_LIST);
191+
192+ if (!success) {
193+ MONITOR_INC(MONITOR_FLUSH_SYNC_WAITS);
194+ }
195+
196+ MONITOR_INC_VALUE_CUMULATIVE(
197+ MONITOR_FLUSH_SYNC_TOTAL_PAGE,
198+ MONITOR_FLUSH_SYNC_COUNT,
199+ MONITOR_FLUSH_SYNC_PAGES,
200+ n_pages);
201+
202+ return(success);
203+ }
204+
205+ ut_ad(srv_foreground_preflush == SRV_FOREGROUND_PREFLUSH_EXP_BACKOFF);
206+
207+ current_oldest = buf_pool_get_oldest_modification();
208+ i = 0;
209+
210+ while (buf_page_cleaner_is_active && current_oldest < new_oldest
211+ && current_oldest) {
212+
213+ os_thread_sleep(ut_rnd_interval(0, 1 << i));
214+ i++;
215+ i %= 16;
216+
217+ current_oldest = buf_pool_get_oldest_modification();
218+ }
219+
220+ return(current_oldest >= new_oldest || !current_oldest);
221 }
222
223 /******************************************************//**
224
225=== modified file 'Percona-Server/storage/innobase/srv/srv0srv.cc'
226--- Percona-Server/storage/innobase/srv/srv0srv.cc 2013-10-03 12:42:40 +0000
227+++ Percona-Server/storage/innobase/srv/srv0srv.cc 2013-10-03 13:54:00 +0000
228@@ -261,6 +261,10 @@
229 UNIV_INTERN ulint srv_mem_pool_size = ULINT_MAX;
230 UNIV_INTERN ulint srv_lock_table_size = ULINT_MAX;
231
232+/** Query thread preflush algorithm */
233+UNIV_INTERN ulint srv_foreground_preflush
234+ = SRV_FOREGROUND_PREFLUSH_EXP_BACKOFF;
235+
236 /** The maximum time limit for a single LRU tail flush iteration by the page
237 cleaner thread */
238 UNIV_INTERN ulint srv_cleaner_max_lru_time = 1000;

Subscribers

People subscribed via source and target branches