Merge lp:~percona-dev/percona-server/release-5.1.52-12-bug643463 into lp:~percona-dev/percona-server/release-5.1.52-12

Proposed by Alexey Kopytov
Status: Merged
Approved by: Vadim Tkachenko
Approved revision: no longer in the source branch.
Merged at revision: 139
Proposed branch: lp:~percona-dev/percona-server/release-5.1.52-12-bug643463
Merge into: lp:~percona-dev/percona-server/release-5.1.52-12
Diff against target: 248 lines (+236/-0)
2 files modified
innodb_fast_shutdown.patch (+235/-0)
series (+1/-0)
To merge this branch: bzr merge lp:~percona-dev/percona-server/release-5.1.52-12-bug643463
Reviewer Review Type Date Requested Status
Vadim Tkachenko Approve
Fred Linhoss (community) documentation Approve
Review via email: mp+40644@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

Please rename patch to have more descriptive name, i.e innodb_fast_shutdown.

review: Needs Fixing
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

Fred,
it has to be documented on wiki.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

> Please rename patch to have more descriptive name, i.e innodb_fast_shutdown.
Done.

Revision history for this message
Yasufumi Kinoshita (yasufumi-kinoshita) wrote :

innodb_fast_shutdown is existed variable name already...
Is it related to the variavle?
Why do you choose more confusable name than "bug643463"?

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Note that this patch will unlikely provide any measurable benefits for production systems (decreasing shutdown time by at most 10 seconds does not look significant).

It's the test suite that will mostly benefit from this patch, where there are many server restarts. So this patch looks more like a bugfix to me rather than a new feature.

Does it really make sense to give it a descriptive name?

Revision history for this message
Fred Linhoss (fred-linhoss) :
review: Approve (documentation)
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

ok to merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'innodb_fast_shutdown.patch'
--- innodb_fast_shutdown.patch 1970-01-01 00:00:00 +0000
+++ innodb_fast_shutdown.patch 2010-11-16 18:46:59 +0000
@@ -0,0 +1,235 @@
1# name : innodb_fast_shutdown
2# introduced : 13
3# maintainer : Alexey
4#
5# Shutting down XtraDB takes uninterruptible sleep()s up to 10
6# seconds, even when there is no actual work to do during shutdown.
7#
8# This patch removes most such delays during shutdown, as found using
9# PMP. This makes standard test run very close in speed to with
10# --loose-innodb-fast-shutdown=2, and greatly speeds up running the test
11# suite.
12#
13# The patch also implements os_event_wait_time() for POSIX systems.
14--- /dev/null 1970-01-01 00:00:00.000000000 +0000
15+++ b/COPYING.innodb_fast_shutdown 2010-11-16 21:37:51.000000000 +0300
16@@ -0,0 +1,10 @@
17+Copyright (c) 2010, Kristian Nielsen
18+All rights reserved.
19+
20+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
21+
22+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
23+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
24+ * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
25+
26+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27--- a/storage/innodb_plugin/include/os0sync.h 2010-11-16 21:33:00.000000000 +0300
28+++ b/storage/innodb_plugin/include/os0sync.h 2010-11-16 21:34:06.000000000 +0300
29@@ -189,14 +189,14 @@
30
31 /**********************************************************//**
32 Waits for an event object until it is in the signaled state or
33-a timeout is exceeded. In Unix the timeout is always infinite.
34+a timeout is exceeded.
35 @return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
36 UNIV_INTERN
37 ulint
38 os_event_wait_time(
39 /*===============*/
40 os_event_t event, /*!< in: event to wait */
41- ulint time); /*!< in: timeout in microseconds, or
42+ ulint wtime); /*!< in: timeout in microseconds, or
43 OS_SYNC_INFINITE_TIME */
44 #ifdef __WIN__
45 /**********************************************************//**
46--- a/storage/innodb_plugin/include/srv0srv.h 2010-11-16 21:33:00.000000000 +0300
47+++ b/storage/innodb_plugin/include/srv0srv.h 2010-11-16 21:34:06.000000000 +0300
48@@ -57,6 +57,9 @@
49 thread starts running */
50 extern os_event_t srv_lock_timeout_thread_event;
51
52+/* This event is set at shutdown to wakeup threads from sleep */
53+extern os_event_t srv_shutdown_event;
54+
55 /* If the last data file is auto-extended, we add this many pages to it
56 at a time */
57 #define SRV_AUTO_EXTEND_INCREMENT \
58--- a/storage/innodb_plugin/log/log0log.c 2010-11-16 21:33:00.000000000 +0300
59+++ b/storage/innodb_plugin/log/log0log.c 2010-11-16 21:34:06.000000000 +0300
60@@ -3102,6 +3102,7 @@
61 algorithm only works if the server is idle at shutdown */
62
63 srv_shutdown_state = SRV_SHUTDOWN_CLEANUP;
64+ os_event_set(srv_shutdown_event);
65 loop:
66 os_thread_sleep(100000);
67
68--- a/storage/innodb_plugin/os/os0sync.c 2010-11-16 21:33:00.000000000 +0300
69+++ b/storage/innodb_plugin/os/os0sync.c 2010-11-16 21:34:06.000000000 +0300
70@@ -31,6 +31,9 @@
71
72 #ifdef __WIN__
73 #include <windows.h>
74+#else
75+#include <sys/time.h>
76+#include <time.h>
77 #endif
78
79 #include "ut0mem.h"
80@@ -407,14 +410,14 @@
81
82 /**********************************************************//**
83 Waits for an event object until it is in the signaled state or
84-a timeout is exceeded. In Unix the timeout is always infinite.
85+a timeout is exceeded.
86 @return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
87 UNIV_INTERN
88 ulint
89 os_event_wait_time(
90 /*===============*/
91 os_event_t event, /*!< in: event to wait */
92- ulint time) /*!< in: timeout in microseconds, or
93+ ulint wtime) /*!< in: timeout in microseconds, or
94 OS_SYNC_INFINITE_TIME */
95 {
96 #ifdef __WIN__
97@@ -422,8 +425,8 @@
98
99 ut_a(event);
100
101- if (time != OS_SYNC_INFINITE_TIME) {
102- err = WaitForSingleObject(event->handle, (DWORD) time / 1000);
103+ if (wtime != OS_SYNC_INFINITE_TIME) {
104+ err = WaitForSingleObject(event->handle, (DWORD) wtime / 1000);
105 } else {
106 err = WaitForSingleObject(event->handle, INFINITE);
107 }
108@@ -439,13 +442,47 @@
109 return(1000000); /* dummy value to eliminate compiler warn. */
110 }
111 #else
112- UT_NOT_USED(time);
113+ int err;
114+ int ret = 0;
115+ ulint tmp;
116+ ib_int64_t old_count;
117+ struct timeval tv_start;
118+ struct timespec timeout;
119+
120+ if (wtime == OS_SYNC_INFINITE_TIME) {
121+ os_event_wait(event);
122+ return 0;
123+ }
124+
125+ /* Compute the absolute point in time at which to time out. */
126+ gettimeofday(&tv_start, NULL);
127+ tmp = tv_start.tv_usec + wtime;
128+ timeout.tv_sec = tv_start.tv_sec + (tmp / 1000000);
129+ timeout.tv_nsec = (tmp % 1000000) * 1000;
130+
131+ os_fast_mutex_lock(&(event->os_mutex));
132+ old_count = event->signal_count;
133
134- /* In Posix this is just an ordinary, infinite wait */
135+ for (;;) {
136+ if (event->is_set == TRUE || event->signal_count != old_count)
137+ break;
138+
139+ err = pthread_cond_timedwait(&(event->cond_var),
140+ &(event->os_mutex), &timeout);
141+ if (err == ETIMEDOUT) {
142+ ret = OS_SYNC_TIME_EXCEEDED;
143+ break;
144+ }
145+ }
146
147- os_event_wait(event);
148+ os_fast_mutex_unlock(&(event->os_mutex));
149+
150+ if (srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS) {
151+
152+ os_thread_exit(NULL);
153+ }
154
155- return(0);
156+ return ret;
157 #endif
158 }
159
160--- a/storage/innodb_plugin/srv/srv0srv.c 2010-11-16 21:33:00.000000000 +0300
161+++ b/storage/innodb_plugin/srv/srv0srv.c 2010-11-16 21:34:06.000000000 +0300
162@@ -704,6 +704,8 @@
163
164 UNIV_INTERN os_event_t srv_lock_timeout_thread_event;
165
166+UNIV_INTERN os_event_t srv_shutdown_event;
167+
168 UNIV_INTERN srv_sys_t* srv_sys = NULL;
169
170 /* padding to prevent other memory update hotspots from residing on
171@@ -1009,6 +1011,7 @@
172 }
173
174 srv_lock_timeout_thread_event = os_event_create(NULL);
175+ srv_shutdown_event = os_event_create(NULL);
176
177 for (i = 0; i < SRV_MASTER + 1; i++) {
178 srv_n_threads_active[i] = 0;
179@@ -2236,7 +2239,7 @@
180 /* Wake up every 5 seconds to see if we need to print
181 monitor information. */
182
183- os_thread_sleep(5000000);
184+ os_event_wait_time(srv_shutdown_event, 5000000);
185
186 current_time = time(NULL);
187
188@@ -2378,7 +2381,7 @@
189 /* When someone is waiting for a lock, we wake up every second
190 and check if a timeout has passed for a lock wait */
191
192- os_thread_sleep(1000000);
193+ os_event_wait_time(srv_shutdown_event, 1000000);
194
195 srv_lock_timeout_active = TRUE;
196
197@@ -2543,7 +2546,7 @@
198
199 fflush(stderr);
200
201- os_thread_sleep(1000000);
202+ os_event_wait_time(srv_shutdown_event, 1000000);
203
204 if (srv_shutdown_state < SRV_SHUTDOWN_CLEANUP) {
205
206@@ -2587,7 +2590,7 @@
207 last_dump_time = time(NULL);
208
209 loop:
210- os_thread_sleep(5000000);
211+ os_event_wait_time(srv_shutdown_event, 5000000);
212
213 if (srv_shutdown_state >= SRV_SHUTDOWN_CLEANUP) {
214 goto exit_func;
215@@ -2751,7 +2754,7 @@
216
217 if (!skip_sleep) {
218
219- os_thread_sleep(1000000);
220+ os_event_wait_time(srv_shutdown_event, 1000000);
221 srv_main_sleeps++;
222
223 /*
224@@ -3337,9 +3340,10 @@
225 mutex_exit(&kernel_mutex);
226
227 sleep_ms = 10;
228+ os_event_reset(srv_shutdown_event);
229 }
230
231- os_thread_sleep( sleep_ms * 1000 );
232+ os_event_wait_time(srv_shutdown_event, sleep_ms * 1000);
233
234 history_len = trx_sys->rseg_history_len;
235 if (history_len > 1000)
0236
=== modified file 'series'
--- series 2010-10-29 09:20:36 +0000
+++ series 2010-11-16 18:46:59 +0000
@@ -49,3 +49,4 @@
49remove_fcntl_excessive_calls.patch49remove_fcntl_excessive_calls.patch
50sql_no_fcache.patch50sql_no_fcache.patch
51show_slave_status_nolock.patch51show_slave_status_nolock.patch
52innodb_fast_shutdow.patch

Subscribers

People subscribed via source and target branches

to all changes: