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

Subscribers

People subscribed via source and target branches

to all changes: