Merge lp:~laurynas-biveinis/percona-server/xtradb-thread-nice 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: 451
Proposed branch: lp:~laurynas-biveinis/percona-server/xtradb-thread-nice
Merge into: lp:percona-server/5.6
Diff against target: 972 lines (+664/-22)
20 files modified
Percona-Server/mysql-test/include/linux.inc (+5/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test (+42/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test (+43/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test (+43/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test (+43/-0)
Percona-Server/storage/innobase/buf/buf0flu.cc (+4/-0)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+197/-1)
Percona-Server/storage/innobase/include/os0thread.h (+35/-0)
Percona-Server/storage/innobase/include/srv0srv.h (+26/-0)
Percona-Server/storage/innobase/os/os0thread.cc (+52/-0)
Percona-Server/storage/innobase/srv/srv0srv.cc (+39/-0)
Percona-Server/storage/innobase/srv/srv0start.cc (+11/-1)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/xtradb-thread-nice
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 Approve
Vadim Tkachenko Pending
Review via email: mp+189018@code.launchpad.net

This proposal supersedes a proposal from 2013-10-02.

Description of the change

2nd MP:

    Changes from the 1st MP:
    - created mysql-test/include/linux.inc, used from the test files
      added by current and previous MPs.
    - Made srv_sched_priority_* variables unconditionally declared.

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

1st MP:

Implement relative thread scheduling priorities for XtraDB
(https://blueprints.launchpad.net/percona-server/+spec/xtradb-thread-nice).

Add new command line option innodb_sched_priority_cleaner=0..39,
corresponding to Linux nice values of -20..19. Add other options
innodb_sched_priority_purge, innodb_sched_priority_io,
innodb_sched_priority_master, hidden under UNIV_PERF_DEBUG.

On setting the new values, silently do nothing if a corresponding
thread or threads are not running. If they are running, attempt to
set the thread nice priority for the specified thread type and return
a warning with an actual priority if the attempt failed.

As Linux setpriority() accepts as system-specific pid_t thread id,
define a new type os_tid_t. Implement new functions
os_thread_get_tid() and os_thread_set_priority() that use it.

Introduce a new macro SRV_MAX_N_PURGE_THREADS for the maximum allowed
number of purge threads.

Add new sys_vars test for these variables.

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

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

LGTM from logical point of view.

review: Approve
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

Hi Laurynas,

I noted a lot of OS checks in tests, would be nice to have file have_linux.inc and use it. Also "Linux" (double quotes) is not compatible with MySQL ansi mode, not sure if it is important. Introduction of have_linux will probably not save a lot of code lines, but will save a bit of time for those who need to implement that check in future. One can easily find have_linux.inc and use it instead of digging the actual way how check OS.

Otherwise looks good.

review: Needs Fixing (g2)
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

There are also lines in test cases which are commented out.
diff lines 165-168,177,178,217-220,229,230,269-272,281,282,321-324,333,334

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

srv_sched_priority_cleaner in srv0srv.h but is UNIV_LINUX only, but it used in buf0flu.cc (buf_flush_page_cleaner_thread) without UNIV_LINUX. Likewise other srv_sched_priority_* variables.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Sergei -

> There are also lines in test cases which are commented out.
> diff lines 165-168,177,178,217-220,229,230,269-272,281,282,321-324,333,334

Diff line 164 explained this: these are the valid values for the variable, but the test would not necessarily succeed as it needs ulimit setup. Thus leave them in the test to show the legal values, but do not attempt to execute them.

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/include/linux.inc'
2--- Percona-Server/mysql-test/include/linux.inc 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/include/linux.inc 2013-10-03 09:38:30 +0000
4@@ -0,0 +1,5 @@
5+if (`select convert(@@version_compile_os using latin1) LIKE 'Linux' = 0`)
6+{
7+ skip Need Linux;
8+}
9+
10
11=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result'
12--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result 1970-01-01 00:00:00 +0000
13+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result 2013-10-03 09:38:30 +0000
14@@ -0,0 +1,30 @@
15+SET @start_value = @@GLOBAL.innodb_sched_priority_cleaner;
16+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
17+@@GLOBAL.innodb_sched_priority_cleaner
18+20
19+SELECT @@SESSION.innodb_sched_priority_cleaner;
20+ERROR HY000: Variable 'innodb_sched_priority_cleaner' is a GLOBAL variable
21+SET GLOBAL innodb_sched_priority_cleaner=20;
22+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
23+@@GLOBAL.innodb_sched_priority_cleaner
24+20
25+SET GLOBAL innodb_sched_priority_cleaner=25;
26+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
27+@@GLOBAL.innodb_sched_priority_cleaner
28+25
29+SET GLOBAL innodb_sched_priority_cleaner=39;
30+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
31+@@GLOBAL.innodb_sched_priority_cleaner
32+39
33+SET GLOBAL innodb_sched_priority_cleaner=41;
34+Warnings:
35+Warning 1292 Truncated incorrect innodb_sched_priority_cleaner value: '41'
36+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
37+@@GLOBAL.innodb_sched_priority_cleaner
38+39
39+SET GLOBAL innodb_sched_priority_cleaner=1.1;
40+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_cleaner'
41+SET GLOBAL innodb_sched_priority_cleaner=1e1;
42+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_cleaner'
43+SET GLOBAL innodb_sched_priority_cleaner='foo';
44+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_cleaner'
45
46=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result'
47--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result 1970-01-01 00:00:00 +0000
48+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result 2013-10-03 09:38:30 +0000
49@@ -0,0 +1,30 @@
50+SET @start_value = @@GLOBAL.innodb_sched_priority_io;
51+SELECT @@GLOBAL.innodb_sched_priority_io;
52+@@GLOBAL.innodb_sched_priority_io
53+20
54+SELECT @@SESSION.innodb_sched_priority_io;
55+ERROR HY000: Variable 'innodb_sched_priority_io' is a GLOBAL variable
56+SET GLOBAL innodb_sched_priority_io=20;
57+SELECT @@GLOBAL.innodb_sched_priority_io;
58+@@GLOBAL.innodb_sched_priority_io
59+20
60+SET GLOBAL innodb_sched_priority_io=25;
61+SELECT @@GLOBAL.innodb_sched_priority_io;
62+@@GLOBAL.innodb_sched_priority_io
63+25
64+SET GLOBAL innodb_sched_priority_io=39;
65+SELECT @@GLOBAL.innodb_sched_priority_io;
66+@@GLOBAL.innodb_sched_priority_io
67+39
68+SET GLOBAL innodb_sched_priority_io=41;
69+Warnings:
70+Warning 1292 Truncated incorrect innodb_sched_priority_io value: '41'
71+SELECT @@GLOBAL.innodb_sched_priority_io;
72+@@GLOBAL.innodb_sched_priority_io
73+39
74+SET GLOBAL innodb_sched_priority_io=1.1;
75+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_io'
76+SET GLOBAL innodb_sched_priority_io=1e1;
77+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_io'
78+SET GLOBAL innodb_sched_priority_io='foo';
79+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_io'
80
81=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result'
82--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result 1970-01-01 00:00:00 +0000
83+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result 2013-10-03 09:38:30 +0000
84@@ -0,0 +1,30 @@
85+SET @start_value = @@GLOBAL.innodb_sched_priority_master;
86+SELECT @@GLOBAL.innodb_sched_priority_master;
87+@@GLOBAL.innodb_sched_priority_master
88+20
89+SELECT @@SESSION.innodb_sched_priority_master;
90+ERROR HY000: Variable 'innodb_sched_priority_master' is a GLOBAL variable
91+SET GLOBAL innodb_sched_priority_master=20;
92+SELECT @@GLOBAL.innodb_sched_priority_master;
93+@@GLOBAL.innodb_sched_priority_master
94+20
95+SET GLOBAL innodb_sched_priority_master=25;
96+SELECT @@GLOBAL.innodb_sched_priority_master;
97+@@GLOBAL.innodb_sched_priority_master
98+25
99+SET GLOBAL innodb_sched_priority_master=39;
100+SELECT @@GLOBAL.innodb_sched_priority_master;
101+@@GLOBAL.innodb_sched_priority_master
102+39
103+SET GLOBAL innodb_sched_priority_master=41;
104+Warnings:
105+Warning 1292 Truncated incorrect innodb_sched_priority_master value: '41'
106+SELECT @@GLOBAL.innodb_sched_priority_master;
107+@@GLOBAL.innodb_sched_priority_master
108+39
109+SET GLOBAL innodb_sched_priority_master=1.1;
110+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_master'
111+SET GLOBAL innodb_sched_priority_master=1e1;
112+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_master'
113+SET GLOBAL innodb_sched_priority_master='foo';
114+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_master'
115
116=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result'
117--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result 1970-01-01 00:00:00 +0000
118+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result 2013-10-03 09:38:30 +0000
119@@ -0,0 +1,30 @@
120+SET @start_value = @@GLOBAL.innodb_sched_priority_purge;
121+SELECT @@GLOBAL.innodb_sched_priority_purge;
122+@@GLOBAL.innodb_sched_priority_purge
123+20
124+SELECT @@SESSION.innodb_sched_priority_purge;
125+ERROR HY000: Variable 'innodb_sched_priority_purge' is a GLOBAL variable
126+SET GLOBAL innodb_sched_priority_purge=20;
127+SELECT @@GLOBAL.innodb_sched_priority_purge;
128+@@GLOBAL.innodb_sched_priority_purge
129+20
130+SET GLOBAL innodb_sched_priority_purge=25;
131+SELECT @@GLOBAL.innodb_sched_priority_purge;
132+@@GLOBAL.innodb_sched_priority_purge
133+25
134+SET GLOBAL innodb_sched_priority_purge=39;
135+SELECT @@GLOBAL.innodb_sched_priority_purge;
136+@@GLOBAL.innodb_sched_priority_purge
137+39
138+SET GLOBAL innodb_sched_priority_purge=41;
139+Warnings:
140+Warning 1292 Truncated incorrect innodb_sched_priority_purge value: '41'
141+SELECT @@GLOBAL.innodb_sched_priority_purge;
142+@@GLOBAL.innodb_sched_priority_purge
143+39
144+SET GLOBAL innodb_sched_priority_purge=1.1;
145+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_purge'
146+SET GLOBAL innodb_sched_priority_purge=1e1;
147+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_purge'
148+SET GLOBAL innodb_sched_priority_purge='foo';
149+ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_purge'
150
151=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test'
152--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test 2013-09-23 12:31:09 +0000
153+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test 2013-10-03 09:38:30 +0000
154@@ -1,10 +1,6 @@
155 --source include/have_debug.inc
156 --source include/have_innodb.inc
157-
158-if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
159-{
160- skip Needs Linux;
161-}
162+--source include/linux.inc
163
164 # A dynamic, global variable
165
166
167=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test'
168--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test 2013-09-23 12:31:09 +0000
169+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test 2013-10-03 09:38:30 +0000
170@@ -1,10 +1,6 @@
171 --source include/have_debug.inc
172 --source include/have_innodb.inc
173-
174-if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
175-{
176- skip Needs Linux;
177-}
178+--source include/linux.inc
179
180 # A dynamic, global variable
181
182
183=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test'
184--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test 2013-09-23 12:31:09 +0000
185+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test 2013-10-03 09:38:30 +0000
186@@ -1,10 +1,6 @@
187 --source include/have_debug.inc
188 --source include/have_innodb.inc
189-
190-if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
191-{
192- skip Needs Linux;
193-}
194+--source include/linux.inc
195
196 # A dynamic, global variable
197
198
199=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test'
200--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test 2013-09-23 12:31:09 +0000
201+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test 2013-10-03 09:38:30 +0000
202@@ -1,10 +1,6 @@
203 --source include/have_debug.inc
204 --source include/have_innodb.inc
205-
206-if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
207-{
208- skip Needs Linux;
209-}
210+--source include/linux.inc
211
212 # A dynamic, global variable
213
214
215=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test'
216--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test 1970-01-01 00:00:00 +0000
217+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test 2013-10-03 09:38:30 +0000
218@@ -0,0 +1,42 @@
219+--source include/have_innodb.inc
220+--source include/linux.inc
221+
222+# A dynamic, global variable
223+
224+SET @start_value = @@GLOBAL.innodb_sched_priority_cleaner;
225+
226+# Default value
227+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
228+
229+# Global only
230+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
231+SELECT @@SESSION.innodb_sched_priority_cleaner;
232+
233+# Correct values
234+# The high priority values may need permissions, thus do not test them
235+# SET GLOBAL innodb_sched_priority_cleaner=0;
236+# SELECT @@GLOBAL.innodb_sched_priority_cleaner;
237+#SET GLOBAL innodb_sched_priority_cleaner=15;
238+# SELECT @@GLOBAL.innodb_sched_priority_cleaner;
239+SET GLOBAL innodb_sched_priority_cleaner=20;
240+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
241+SET GLOBAL innodb_sched_priority_cleaner=25;
242+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
243+SET GLOBAL innodb_sched_priority_cleaner=39;
244+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
245+
246+# Incorrect values
247+#SET GLOBAL innodb_sched_priority_cleaner=-1;
248+#SELECT @@GLOBAL.innodb_sched_priority_cleaner;
249+SET GLOBAL innodb_sched_priority_cleaner=41;
250+SELECT @@GLOBAL.innodb_sched_priority_cleaner;
251+--error ER_WRONG_TYPE_FOR_VAR
252+SET GLOBAL innodb_sched_priority_cleaner=1.1;
253+--error ER_WRONG_TYPE_FOR_VAR
254+SET GLOBAL innodb_sched_priority_cleaner=1e1;
255+--error ER_WRONG_TYPE_FOR_VAR
256+SET GLOBAL innodb_sched_priority_cleaner='foo';
257+
258+# If we are lacking permissions, then we cannot restore the startup value
259+# at the end.
260+--source include/restart_mysqld.inc
261
262=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test'
263--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test 1970-01-01 00:00:00 +0000
264+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test 2013-10-03 09:38:30 +0000
265@@ -0,0 +1,43 @@
266+--source include/have_debug.inc
267+--source include/have_innodb.inc
268+--source include/linux.inc
269+
270+# A dynamic, global variable
271+
272+SET @start_value = @@GLOBAL.innodb_sched_priority_io;
273+
274+# Default value
275+SELECT @@GLOBAL.innodb_sched_priority_io;
276+
277+# Global only
278+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
279+SELECT @@SESSION.innodb_sched_priority_io;
280+
281+# Correct values
282+# The high priority values may need permissions, thus do not test them
283+# SET GLOBAL innodb_sched_priority_io=0;
284+# SELECT @@GLOBAL.innodb_sched_priority_io;
285+#SET GLOBAL innodb_sched_priority_io=15;
286+# SELECT @@GLOBAL.innodb_sched_priority_io;
287+SET GLOBAL innodb_sched_priority_io=20;
288+SELECT @@GLOBAL.innodb_sched_priority_io;
289+SET GLOBAL innodb_sched_priority_io=25;
290+SELECT @@GLOBAL.innodb_sched_priority_io;
291+SET GLOBAL innodb_sched_priority_io=39;
292+SELECT @@GLOBAL.innodb_sched_priority_io;
293+
294+# Incorrect values
295+#SET GLOBAL innodb_sched_priority_io=-1;
296+#SELECT @@GLOBAL.innodb_sched_priority_io;
297+SET GLOBAL innodb_sched_priority_io=41;
298+SELECT @@GLOBAL.innodb_sched_priority_io;
299+--error ER_WRONG_TYPE_FOR_VAR
300+SET GLOBAL innodb_sched_priority_io=1.1;
301+--error ER_WRONG_TYPE_FOR_VAR
302+SET GLOBAL innodb_sched_priority_io=1e1;
303+--error ER_WRONG_TYPE_FOR_VAR
304+SET GLOBAL innodb_sched_priority_io='foo';
305+
306+# If we are lacking permissions, then we cannot restore the startup value
307+# at the end.
308+--source include/restart_mysqld.inc
309
310=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test'
311--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test 1970-01-01 00:00:00 +0000
312+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test 2013-10-03 09:38:30 +0000
313@@ -0,0 +1,43 @@
314+--source include/have_debug.inc
315+--source include/have_innodb.inc
316+--source include/linux.inc
317+
318+# A dynamic, global variable
319+
320+SET @start_value = @@GLOBAL.innodb_sched_priority_master;
321+
322+# Default value
323+SELECT @@GLOBAL.innodb_sched_priority_master;
324+
325+# Global only
326+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
327+SELECT @@SESSION.innodb_sched_priority_master;
328+
329+# Correct values
330+# The high priority values may need permissions, thus do not test them
331+# SET GLOBAL innodb_sched_priority_master=0;
332+# SELECT @@GLOBAL.innodb_sched_priority_master;
333+#SET GLOBAL innodb_sched_priority_master=15;
334+# SELECT @@GLOBAL.innodb_sched_priority_master;
335+SET GLOBAL innodb_sched_priority_master=20;
336+SELECT @@GLOBAL.innodb_sched_priority_master;
337+SET GLOBAL innodb_sched_priority_master=25;
338+SELECT @@GLOBAL.innodb_sched_priority_master;
339+SET GLOBAL innodb_sched_priority_master=39;
340+SELECT @@GLOBAL.innodb_sched_priority_master;
341+
342+# Incorrect values
343+#SET GLOBAL innodb_sched_priority_master=-1;
344+#SELECT @@GLOBAL.innodb_sched_priority_master;
345+SET GLOBAL innodb_sched_priority_master=41;
346+SELECT @@GLOBAL.innodb_sched_priority_master;
347+--error ER_WRONG_TYPE_FOR_VAR
348+SET GLOBAL innodb_sched_priority_master=1.1;
349+--error ER_WRONG_TYPE_FOR_VAR
350+SET GLOBAL innodb_sched_priority_master=1e1;
351+--error ER_WRONG_TYPE_FOR_VAR
352+SET GLOBAL innodb_sched_priority_master='foo';
353+
354+# If we are lacking permissions, then we cannot restore the startup value
355+# at the end.
356+--source include/restart_mysqld.inc
357
358=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test'
359--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test 1970-01-01 00:00:00 +0000
360+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test 2013-10-03 09:38:30 +0000
361@@ -0,0 +1,43 @@
362+--source include/have_debug.inc
363+--source include/have_innodb.inc
364+--source include/linux.inc
365+
366+# A dynamic, global variable
367+
368+SET @start_value = @@GLOBAL.innodb_sched_priority_purge;
369+
370+# Default value
371+SELECT @@GLOBAL.innodb_sched_priority_purge;
372+
373+# Global only
374+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
375+SELECT @@SESSION.innodb_sched_priority_purge;
376+
377+# Correct values
378+# The high priority values may need permissions, thus do not test them
379+# SET GLOBAL innodb_sched_priority_purge=0;
380+# SELECT @@GLOBAL.innodb_sched_priority_purge;
381+#SET GLOBAL innodb_sched_priority_purge=15;
382+# SELECT @@GLOBAL.innodb_sched_priority_purge;
383+SET GLOBAL innodb_sched_priority_purge=20;
384+SELECT @@GLOBAL.innodb_sched_priority_purge;
385+SET GLOBAL innodb_sched_priority_purge=25;
386+SELECT @@GLOBAL.innodb_sched_priority_purge;
387+SET GLOBAL innodb_sched_priority_purge=39;
388+SELECT @@GLOBAL.innodb_sched_priority_purge;
389+
390+# Incorrect values
391+#SET GLOBAL innodb_sched_priority_purge=-1;
392+#SELECT @@GLOBAL.innodb_sched_priority_purge;
393+SET GLOBAL innodb_sched_priority_purge=41;
394+SELECT @@GLOBAL.innodb_sched_priority_purge;
395+--error ER_WRONG_TYPE_FOR_VAR
396+SET GLOBAL innodb_sched_priority_purge=1.1;
397+--error ER_WRONG_TYPE_FOR_VAR
398+SET GLOBAL innodb_sched_priority_purge=1e1;
399+--error ER_WRONG_TYPE_FOR_VAR
400+SET GLOBAL innodb_sched_priority_purge='foo';
401+
402+# If we are lacking permissions, then we cannot restore the startup value
403+# at the end.
404+--source include/restart_mysqld.inc
405
406=== modified file 'Percona-Server/storage/innobase/buf/buf0flu.cc'
407--- Percona-Server/storage/innobase/buf/buf0flu.cc 2013-10-03 05:38:15 +0000
408+++ Percona-Server/storage/innobase/buf/buf0flu.cc 2013-10-03 09:38:30 +0000
409@@ -2633,6 +2633,10 @@
410 pfs_register_thread(buf_page_cleaner_thread_key);
411 #endif /* UNIV_PFS_THREAD */
412
413+ srv_cleaner_tid = os_thread_get_tid();
414+
415+ os_thread_set_priority(srv_cleaner_tid, srv_sched_priority_cleaner);
416+
417 #ifdef UNIV_DEBUG_THREAD_CREATION
418 fprintf(stderr, "InnoDB: page_cleaner thread running, id %lu\n",
419 os_thread_pf(os_thread_get_curr_id()));
420
421=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
422--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-09-30 12:13:10 +0000
423+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-10-03 09:38:30 +0000
424@@ -15714,6 +15714,172 @@
425 }
426 }
427
428+#ifdef UNIV_LINUX
429+
430+/****************************************************************//**
431+Update the innodb_sched_priority_cleaner variable and set the thread
432+priority accordingly. */
433+static
434+void
435+innodb_sched_priority_cleaner_update(
436+/*=================================*/
437+ THD* thd, /*!< in: thread handle */
438+ struct st_mysql_sys_var* var, /*!< in: pointer to
439+ system variable */
440+ void* var_ptr,/*!< out: where the
441+ formal string goes */
442+ const void* save) /*!< in: immediate result
443+ from check function */
444+{
445+ ulint priority = *static_cast<const ulint *>(save);
446+ ulint actual_priority;
447+
448+ if (srv_read_only_mode) {
449+
450+ return;
451+ }
452+
453+ ut_ad(buf_page_cleaner_is_active);
454+ actual_priority = os_thread_set_priority(srv_cleaner_tid, priority);
455+ if (UNIV_UNLIKELY(actual_priority != priority)) {
456+
457+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
458+ ER_WRONG_ARGUMENTS,
459+ "Failed to set the page cleaner thread "
460+ "priority to %lu, "
461+ "the current priority is %lu", priority,
462+ actual_priority);
463+ } else {
464+
465+ srv_sched_priority_cleaner = priority;
466+ }
467+}
468+
469+#if defined(UNIV_DEBUG) || (UNIV_PERF_DEBUG)
470+
471+/****************************************************************//**
472+Update the innodb_sched_priority_purge variable and set the thread
473+priorities accordingly. */
474+static
475+void
476+innodb_sched_priority_purge_update(
477+/*===============================*/
478+ THD* thd, /*!< in: thread handle */
479+ struct st_mysql_sys_var* var, /*!< in: pointer to
480+ system variable */
481+ void* var_ptr,/*!< out: where the
482+ formal string goes */
483+ const void* save) /*!< in: immediate result
484+ from check function */
485+{
486+ ulint priority = *static_cast<const ulint *>(save);
487+
488+ if (srv_read_only_mode) {
489+ return;
490+ }
491+
492+ ut_ad(purge_sys->state == PURGE_STATE_RUN);
493+ for (ulint i = 0; i < srv_n_purge_threads; i++) {
494+
495+ ulint actual_priority
496+ = os_thread_set_priority(srv_purge_tids[i], priority);
497+ if (UNIV_UNLIKELY(actual_priority != priority)) {
498+
499+ push_warning_printf(thd,
500+ Sql_condition::WARN_LEVEL_WARN,
501+ ER_WRONG_ARGUMENTS,
502+ "Failed to set the purge "
503+ "thread priority to %lu, the "
504+ "current priority is %lu, "
505+ "aborting priority update",
506+ priority, actual_priority);
507+ return;
508+ }
509+ }
510+
511+ srv_sched_priority_purge = priority;
512+}
513+
514+/****************************************************************//**
515+Update the innodb_sched_priority_io variable and set the thread
516+priorities accordingly. */
517+static
518+void
519+innodb_sched_priority_io_update(
520+/*============================*/
521+ THD* thd, /*!< in: thread handle */
522+ struct st_mysql_sys_var* var, /*!< in: pointer to
523+ system variable */
524+ void* var_ptr,/*!< out: where the
525+ formal string goes */
526+ const void* save) /*!< in: immediate result
527+ from check function */
528+{
529+ ulint priority = *static_cast<const ulint *>(save);
530+
531+ for (ulint i = 0; i < srv_n_file_io_threads; i++) {
532+
533+ ulint actual_priority = os_thread_set_priority(srv_io_tids[i],
534+ priority);
535+
536+ if (UNIV_UNLIKELY(actual_priority != priority)) {
537+
538+ push_warning_printf(thd,
539+ Sql_condition::WARN_LEVEL_WARN,
540+ ER_WRONG_ARGUMENTS,
541+ "Failed to set the I/O "
542+ "thread priority to %lu, the "
543+ "current priority is %lu, "
544+ "aborting priority update",
545+ priority, actual_priority);
546+ return;
547+ }
548+ }
549+
550+ srv_sched_priority_io = priority;
551+}
552+
553+/****************************************************************//**
554+Update the innodb_sched_priority_master variable and set the thread
555+priorities accordingly. */
556+static
557+void
558+innodb_sched_priority_master_update(
559+/*================================*/
560+ THD* thd, /*!< in: thread handle */
561+ struct st_mysql_sys_var* var, /*!< in: pointer to
562+ system variable */
563+ void* var_ptr,/*!< out: where the
564+ formal string goes */
565+ const void* save) /*!< in: immediate result
566+ from check function */
567+{
568+ ulint priority = *static_cast<const lint *>(save);
569+ ulint actual_priority;
570+
571+ if (srv_read_only_mode) {
572+ return;
573+ }
574+
575+ actual_priority = os_thread_set_priority(srv_master_tid, priority);
576+ if (UNIV_UNLIKELY(actual_priority != priority)) {
577+
578+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
579+ ER_WRONG_ARGUMENTS,
580+ "Failed to set the master thread "
581+ "priority to %lu, "
582+ "the current priority is %lu", priority,
583+ actual_priority);
584+ } else {
585+
586+ srv_sched_priority_master = priority;
587+ }
588+}
589+
590+#endif /* defined(UNIV_DEBUG) || (UNIV_PERF_DEBUG) */
591+
592+#endif /* UNIV_LINUX */
593+
594 /****************************************************************//**
595 Callback function for accessing the InnoDB variables from MySQL:
596 SHOW VARIABLES. */
597@@ -16266,7 +16432,7 @@
598 NULL, NULL,
599 1, /* Default setting */
600 1, /* Minimum value */
601- 32, 0); /* Maximum value */
602+ SRV_MAX_N_PURGE_THREADS, 0); /* Maximum value */
603
604 static MYSQL_SYSVAR_ULONG(sync_array_size, srv_sync_array_size,
605 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
606@@ -16539,6 +16705,15 @@
607 "established by the buffer pool memory region. Disabled by default.",
608 NULL, NULL, FALSE);
609
610+#ifdef UNIV_LINUX
611+
612+static MYSQL_SYSVAR_ULONG(sched_priority_cleaner, srv_sched_priority_cleaner,
613+ PLUGIN_VAR_RQCMDARG,
614+ "Nice value for the cleaner thread scheduling",
615+ NULL, innodb_sched_priority_cleaner_update, 20, 0, 39, 0);
616+
617+#endif /* UNIV_LINUX */
618+
619 #if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG
620 static MYSQL_SYSVAR_ULONG(page_hash_locks, srv_n_page_hash_locks,
621 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
622@@ -16552,6 +16727,21 @@
623
624 #ifdef UNIV_LINUX
625
626+static MYSQL_SYSVAR_ULONG(sched_priority_purge, srv_sched_priority_purge,
627+ PLUGIN_VAR_RQCMDARG,
628+ "Nice value for the purge thread scheduling",
629+ NULL, innodb_sched_priority_purge_update, 20, 0, 39, 0);
630+
631+static MYSQL_SYSVAR_ULONG(sched_priority_io, srv_sched_priority_io,
632+ PLUGIN_VAR_RQCMDARG,
633+ "Nice value for the I/O handler thread scheduling",
634+ NULL, innodb_sched_priority_io_update, 20, 0, 39, 0);
635+
636+static MYSQL_SYSVAR_ULONG(sched_priority_master, srv_sched_priority_master,
637+ PLUGIN_VAR_RQCMDARG,
638+ "Nice value for the master thread scheduling",
639+ NULL, innodb_sched_priority_master_update, 20, 0, 39, 0);
640+
641 static MYSQL_SYSVAR_BOOL(priority_purge, srv_purge_thread_priority,
642 PLUGIN_VAR_OPCMDARG,
643 "Make purge coordinator and worker threads acquire shared resources with "
644@@ -17268,10 +17458,16 @@
645 MYSQL_SYSVAR(log_checkpoint_now),
646 MYSQL_SYSVAR(track_redo_log_now),
647 #endif /* UNIV_DEBUG */
648+#ifdef UNIV_LINUX
649+ MYSQL_SYSVAR(sched_priority_cleaner),
650+#endif
651 #if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG
652 MYSQL_SYSVAR(page_hash_locks),
653 MYSQL_SYSVAR(doublewrite_batch_size),
654 #ifdef UNIV_LINUX
655+ MYSQL_SYSVAR(sched_priority_purge),
656+ MYSQL_SYSVAR(sched_priority_io),
657+ MYSQL_SYSVAR(sched_priority_master),
658 MYSQL_SYSVAR(priority_purge),
659 MYSQL_SYSVAR(priority_io),
660 MYSQL_SYSVAR(priority_cleaner),
661
662=== modified file 'Percona-Server/storage/innobase/include/os0thread.h'
663--- Percona-Server/storage/innobase/include/os0thread.h 2013-06-10 20:44:22 +0000
664+++ Percona-Server/storage/innobase/include/os0thread.h 2013-10-03 09:38:30 +0000
665@@ -29,6 +29,10 @@
666
667 #include "univ.i"
668
669+#ifdef UNIV_LINUX
670+#include <sys/types.h>
671+#endif
672+
673 /* Maximum number of threads which can be created in the program;
674 this is also the size of the wait slot array for MySQL threads which
675 can wait inside InnoDB */
676@@ -45,6 +49,7 @@
677 typedef void* os_thread_t;
678 typedef DWORD os_thread_id_t; /*!< In Windows the thread id
679 is an unsigned long int */
680+typedef os_thread_id_t os_tid_t;
681 extern "C" {
682 typedef LPTHREAD_START_ROUTINE os_thread_func_t;
683 }
684@@ -65,6 +70,15 @@
685 typedef os_thread_t os_thread_id_t; /*!< In Unix we use the thread
686 handle itself as the id of
687 the thread */
688+#ifdef UNIV_LINUX
689+typedef pid_t os_tid_t; /*!< An alias for pid_t on
690+ Linux, where setpriority()
691+ accepts thread id of this type
692+ and not pthread_t */
693+#else
694+typedef os_thread_id_t os_tid_t;
695+#endif
696+
697 extern "C" { typedef void* (*os_thread_func_t)(void*); }
698
699 /** Macro for specifying a POSIX thread start function. */
700@@ -134,6 +148,15 @@
701 os_thread_get_curr_id(void);
702 /*========================*/
703 /*****************************************************************//**
704+Returns the system-specific thread identifier of current thread. On Linux,
705+returns tid. On other systems currently returns os_thread_get_curr_id().
706+
707+@return current thread identifier */
708+UNIV_INTERN
709+os_tid_t
710+os_thread_get_tid(void);
711+/*=====================*/
712+/*****************************************************************//**
713 Advises the os to give up remainder of the thread's time slice. */
714 UNIV_INTERN
715 void
716@@ -146,6 +169,18 @@
717 os_thread_sleep(
718 /*============*/
719 ulint tm); /*!< in: time in microseconds */
720+/*****************************************************************//**
721+Set relative scheduling priority for a given thread on Linux. Currently a
722+no-op on other systems.
723+
724+@return An actual thread priority after the update */
725+UNIV_INTERN
726+ulint
727+os_thread_set_priority(
728+/*===================*/
729+ os_tid_t thread_id, /*!< in: thread id */
730+ ulint relative_priority); /*!< in: system-specific
731+ priority value */
732
733 #ifndef UNIV_NONINL
734 #include "os0thread.ic"
735
736=== modified file 'Percona-Server/storage/innobase/include/srv0srv.h'
737--- Percona-Server/storage/innobase/include/srv0srv.h 2013-09-30 12:13:10 +0000
738+++ Percona-Server/storage/innobase/include/srv0srv.h 2013-10-03 09:38:30 +0000
739@@ -503,11 +503,37 @@
740
741 #define SRV_MAX_N_IO_THREADS 130
742
743+#define SRV_MAX_N_PURGE_THREADS 32
744+
745 /* Array of English strings describing the current state of an
746 i/o handler thread */
747 extern const char* srv_io_thread_op_info[];
748 extern const char* srv_io_thread_function[];
749
750+/* The tid of the cleaner thread */
751+extern os_tid_t srv_cleaner_tid;
752+
753+/* The tids of the purge threads */
754+extern os_tid_t srv_purge_tids[];
755+
756+/* The tids of the I/O threads */
757+extern os_tid_t srv_io_tids[];
758+
759+/* The tid of the master thread */
760+extern os_tid_t srv_master_tid;
761+
762+/* The relative scheduling priority of the cleaner thread */
763+extern ulint srv_sched_priority_cleaner;
764+
765+/* The relative scheduling priority of the purge threads */
766+extern ulint srv_sched_priority_purge;
767+
768+/* The relative scheduling priority of the I/O threads */
769+extern ulint srv_sched_priority_io;
770+
771+/* The relative scheduling priority of the master thread */
772+extern ulint srv_sched_priority_master;
773+
774 /* The relative priority of the purge coordinator and worker threads. */
775 extern my_bool srv_purge_thread_priority;
776
777
778=== modified file 'Percona-Server/storage/innobase/os/os0thread.cc'
779--- Percona-Server/storage/innobase/os/os0thread.cc 2013-06-10 20:44:22 +0000
780+++ Percona-Server/storage/innobase/os/os0thread.cc 2013-10-03 09:38:30 +0000
781@@ -30,6 +30,12 @@
782
783 #ifdef __WIN__
784 #include <windows.h>
785+#elif UNIV_LINUX
786+#include <sys/time.h>
787+#include <sys/resource.h>
788+#include <unistd.h>
789+#include <sys/syscall.h>
790+#include <sys/types.h>
791 #endif
792
793 #ifndef UNIV_HOTBACKUP
794@@ -98,6 +104,24 @@
795 #endif
796 }
797
798+/*****************************************************************//**
799+Returns the system-specific thread identifier of current thread. On Linux,
800+returns tid. On other systems currently returns os_thread_get_curr_id().
801+
802+@return current thread identifier */
803+UNIV_INTERN
804+os_tid_t
805+os_thread_get_tid(void)
806+/*===================*/
807+{
808+#ifdef UNIV_LINUX
809+ return((os_tid_t)syscall(SYS_gettid));
810+#else
811+ return(os_thread_get_curr_id());
812+#endif
813+}
814+
815+
816 /****************************************************************//**
817 Creates a new thread of execution. The execution starts from
818 the function given. The start function takes a void* parameter
819@@ -255,3 +279,31 @@
820 select(0, NULL, NULL, NULL, &t);
821 #endif
822 }
823+
824+/*****************************************************************//**
825+Set relative scheduling priority for a given thread on Linux. Currently a
826+no-op on other systems.
827+
828+@return An actual thread priority after the update */
829+UNIV_INTERN
830+ulint
831+os_thread_set_priority(
832+/*===================*/
833+ os_tid_t thread_id, /*!< in: thread id */
834+ ulint relative_priority) /*!< in: system-specific
835+ priority value */
836+{
837+#ifdef UNIV_LINUX
838+ lint thread_nice = relative_priority - 20;
839+ if (setpriority(PRIO_PROCESS, thread_id, thread_nice) == -1) {
840+ ib_logf(IB_LOG_LEVEL_WARN,
841+ "Setting thread %lu nice to %ld failed, "
842+ "current nice %d, errno %d",
843+ os_thread_pf(thread_id), thread_nice,
844+ getpriority(PRIO_PROCESS, thread_id), errno);
845+ }
846+ return(getpriority(PRIO_PROCESS, thread_id) + 20);
847+#else
848+ return(relative_priority);
849+#endif
850+}
851
852=== modified file 'Percona-Server/storage/innobase/srv/srv0srv.cc'
853--- Percona-Server/storage/innobase/srv/srv0srv.cc 2013-09-30 12:13:10 +0000
854+++ Percona-Server/storage/innobase/srv/srv0srv.cc 2013-10-03 09:38:30 +0000
855@@ -344,6 +344,30 @@
856 /* Number of iterations over which adaptive flushing is averaged. */
857 UNIV_INTERN ulong srv_flushing_avg_loops = 30;
858
859+/* The tid of the cleaner thread */
860+UNIV_INTERN os_tid_t srv_cleaner_tid;
861+
862+/* The tids of the purge threads */
863+UNIV_INTERN os_tid_t srv_purge_tids[SRV_MAX_N_PURGE_THREADS];
864+
865+/* The tids of the I/O threads */
866+UNIV_INTERN os_tid_t srv_io_tids[SRV_MAX_N_IO_THREADS];
867+
868+/* The tid of the master thread */
869+UNIV_INTERN os_tid_t srv_master_tid;
870+
871+/* The relative scheduling priority of the cleaner thread */
872+UNIV_INTERN ulint srv_sched_priority_cleaner = 20;
873+
874+/* The relative scheduling priority of the purge threads */
875+UNIV_INTERN ulint srv_sched_priority_purge = 20;
876+
877+/* The relative scheduling priority of the I/O threads */
878+UNIV_INTERN ulint srv_sched_priority_io = 20;
879+
880+/* The relative scheduling priority of the master thread */
881+UNIV_INTERN ulint srv_sched_priority_master = 20;
882+
883 /* The relative priority of the current thread. If 0, low priority; if 1, high
884 priority. */
885 UNIV_INTERN UNIV_THREAD_LOCAL ulint srv_current_thread_priority = 0;
886@@ -2877,6 +2901,10 @@
887
888 ut_ad(!srv_read_only_mode);
889
890+ srv_master_tid = os_thread_get_tid();
891+
892+ os_thread_set_priority(srv_master_tid, srv_sched_priority_master);
893+
894 #ifdef UNIV_DEBUG_THREAD_CREATION
895 fprintf(stderr, "Master thread starts, id %lu\n",
896 os_thread_pf(os_thread_get_curr_id()));
897@@ -3006,6 +3034,8 @@
898 return(thr != NULL);
899 }
900
901+static ulint purge_tid_i = 0;
902+
903 /*********************************************************************//**
904 Worker thread that reads tasks from the work queue and executes them.
905 @return a dummy parameter */
906@@ -3017,10 +3047,16 @@
907 required by os_thread_create */
908 {
909 srv_slot_t* slot;
910+ ulint tid_i = os_atomic_increment_ulint(&purge_tid_i, 1);
911
912+ ut_ad(tid_i < srv_n_purge_threads);
913 ut_ad(!srv_read_only_mode);
914 ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
915
916+ srv_purge_tids[tid_i] = os_thread_get_tid();
917+ os_thread_set_priority(srv_purge_tids[tid_i],
918+ srv_sched_priority_purge);
919+
920 #ifdef UNIV_DEBUG_THREAD_CREATION
921 ut_print_timestamp(stderr);
922 fprintf(stderr, " InnoDB: worker thread starting, id %lu\n",
923@@ -3286,6 +3322,9 @@
924 ut_a(trx_purge_state() == PURGE_STATE_INIT);
925 ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
926
927+ srv_purge_tids[0] = os_thread_get_tid();
928+ os_thread_set_priority(srv_purge_tids[0], srv_sched_priority_purge);
929+
930 rw_lock_x_lock(&purge_sys->latch);
931
932 purge_sys->running = true;
933
934=== modified file 'Percona-Server/storage/innobase/srv/srv0start.cc'
935--- Percona-Server/storage/innobase/srv/srv0start.cc 2013-09-27 14:09:03 +0000
936+++ Percona-Server/storage/innobase/srv/srv0start.cc 2013-10-03 09:38:30 +0000
937@@ -127,7 +127,8 @@
938 /** io_handler_thread parameters for thread identification */
939 static ulint n[SRV_MAX_N_IO_THREADS + 6];
940 /** io_handler_thread identifiers, 32 is the maximum number of purge threads */
941-static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6 + 32];
942+static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6
943+ + SRV_MAX_N_PURGE_THREADS];
944
945 /** We use this mutex to test the return value of pthread_mutex_trylock
946 on successful locking. HP-UX does NOT return 0, though Linux et al do. */
947@@ -452,6 +453,9 @@
948 }
949
950 #ifndef UNIV_HOTBACKUP
951+
952+static ulint io_tid_i = 0;
953+
954 /********************************************************************//**
955 I/o-handler thread function.
956 @return OS_THREAD_DUMMY_RETURN */
957@@ -463,9 +467,15 @@
958 the aio array */
959 {
960 ulint segment;
961+ ulint tid_i = os_atomic_increment_ulint(&io_tid_i, 1) - 1;
962+
963+ ut_ad(tid_i < srv_n_file_io_threads);
964
965 segment = *((ulint*) arg);
966
967+ srv_io_tids[tid_i] = os_thread_get_tid();
968+ os_thread_set_priority(srv_io_tids[tid_i], srv_sched_priority_io);
969+
970 #ifdef UNIV_DEBUG_THREAD_CREATION
971 fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
972 os_thread_pf(os_thread_get_curr_id()));

Subscribers

People subscribed via source and target branches