Bug #40099 | Provide facilities for preparing the server for faster shutdown. | ||
---|---|---|---|
Submitted: | 17 Oct 2008 7:41 | Modified: | 18 Oct 2008 4:42 |
Reporter: | Simon Mudd (OCA) | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: General | Severity: | S4 (Feature request) |
Version: | OS: | Any | |
Assigned to: | CPU Architecture: | Any |
[17 Oct 2008 7:41]
Simon Mudd
[17 Oct 2008 8:19]
Guilhem Bichot
This reminds me of http://forge.mysql.com/worklog/task.php?id=709 but which is different. However, when working on that task (which ended in an unfinished patch which isn't of much value today - server has changed and patch wasn't perfect), I had a discussion in 2004 with a customer who raised points similar to the ones in this bug report. I'm pasting the most relevant suggestions he and his DBA made, below. They used MyISAM with delay_key_write, like in this bug report, and saw long shutdowns the same way. <quotes> * in shutdown it's important to do as much as possible while connections are being terminated and new connections are still accepted. Flush buffers during this phase, and then repeat the flush when connections are not accepted anymore: this second flush will normally be instant because they'd be nothing left to flush. * Also, tables that are Open but not In Use by any current statement should be flushed first and early so that if the server does get "stuck" and has to be killed the table corruption is limited. This would make a big difference to us - it has been one of the main causes of long database recovery times. * Give more feedback in 'show processlist' about what's happening to a thread that's been "killed". Specifically some way to indicate that a thread has *noticed* that it has been asked to terminate and is now cleaning up. Currently the state is set to "Killed". I suggest setting the state to "Killing" initially and then the thread being killed should change the status to "Killed" once it's noticed. Simple but useful. * It would be nice to be able to have a connection and watch the progress of the shutdown as it's happening. There have been times when I've waited 10 mins or so before killing the mysqld process. If it knew it was progressing I may have waited it out.
[17 Oct 2008 8:42]
Simon Mudd
Yes, the comments from your other user apply in our case too. Often our only reason to shutdown a server is to upgrade it to a newer version which fixes bugs we have been troubled by. Many of our servers are behind load balancers but not all of them and those that aren't mean that shutting down affects our users who have to perform special application shutdown actions ahead of this. Hence we want to reduce this time to a minimum. Extra logging of the shutdown process would also prevents us forcefully killing the server due to simply not knowing what it is doing. This might also help us/MySQL determine exactly what part of the shutdown process is taking longest and at least provide a pointer to which part of the code needs help if we want to reduce this shutdown time. The logging is easy and harmless and could almost certainly be added to 5.0 and later versions. The other changes are probably more obtrusive but it would be nice if they weren't only added to 6.0 or later as for production users this functionality is VERY useful and these versions are so far forward that they are beyond our planning horizon...
[2 Apr 2012 23:38]
jj jj
freshly started mysql server takes 20s to shutdown. Same server running for month takes 20 minutes to shutdown (this means downtime) - even after flush tables!. Shutdown prepare is much needed!!!