Bug #76900 increase stop timeout of community rpm shutdown script /etc/init.d/mysqld
Submitted: 30 Apr 2015 9:39 Modified: 8 May 2015 8:23
Reporter: Simon Mudd (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S3 (Non-critical)
Version:5.7.7 OS:Linux (CentOS 6)
Assigned to: Balasubramanian Kandasamy CPU Architecture:Any
Tags: init script, rpm, timeout

[30 Apr 2015 9:39] Simon Mudd
Description:
I'm trying out 5.7.7 on a few systems and compared to 5.6 they seem to shutdown a bit slower. I notice this causes an issue as the rpm init scripts have a very short default wait time for the shutdown to complete. Tiny servers may shutdown in 60 seconds but many busy or larger servers may take longer to shutdown.  I think it's better to be patient for situations like this.

I see that there's a way via /etc/sysconfig/msyqld to adjust this timeout but I think that it's still worthwhile adjusting the default to are more sensible longer value.

Note: I've not tracked down why the shutdowns seem slower so it may be my perception but the original 5.6 rpm I was using (MySQL-server) don't have such a timeout so I don't have to possibly code any scripting around a shutdown to catch the condition ("mysql didn't shutdown in time").

How to repeat:
When stopping mysqld with /etc/init.d/mysqld I see:

$ sudo tail -f /var/log/mysqld.log
2015-04-30T09:22:34.433512Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2015-04-30T09:22:34.433537Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2015-04-30T09:22:34.433560Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2015-04-30T09:22:34.433584Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2015-04-30T09:22:34.433607Z 0 [Note] Shutting down plugin 'InnoDB'
2015-04-30T09:22:34.433731Z 0 [Note] InnoDB: FTS optimize thread exiting.
2015-04-30T09:22:34.433813Z 0 [Note] InnoDB: Starting shutdown...
2015-04-30T09:22:34.534084Z 0 [Note] InnoDB: Dumping buffer pool(s) to .//ib_buffer_pool
2015-04-30T09:22:35.016699Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 150430 11:22:35
2015-04-30T09:23:35.487961Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:24:35.640045Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:25:35.793513Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:26:35.933597Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:27:36.080358Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:28:36.224341Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:29:36.366294Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:30:36.511100Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:31:36.667904Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:32:36.822694Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2015-04-30T09:32:58.236462Z 0 [Note] InnoDB: Shutdown completed; log sequence number 16364857411420
2015-04-30T09:32:58.236644Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2015-04-30T09:32:58.236671Z 0 [Note] Shutting down plugin 'CSV'
2015-04-30T09:32:58.236696Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2015-04-30T09:32:58.236714Z 0 [Note] Shutting down plugin 'MyISAM'
2015-04-30T09:32:58.236740Z 0 [Note] Shutting down plugin 'MEMORY'
2015-04-30T09:32:58.236761Z 0 [Note] Shutting down plugin 'sha256_password'
2015-04-30T09:32:58.236780Z 0 [Note] Shutting down plugin 'mysql_native_password'
2015-04-30T09:32:58.236945Z 0 [Note] Shutting down plugin 'binlog'
2015-04-30T09:32:58.238017Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

150430 11:32:58 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Suggested fix:
The init script has these settings:

# Set timeouts here so they can be overridden from /etc/sysconfig/mysqld
STARTTIMEOUT=120
STOPTIMEOUT=60

I suggest changing STOPTIMEOUT to 600.

Thought: maybe indicate in the shutdown message how long you're going to wait... That's handy info.
[30 Apr 2015 10:02] Umesh Shastry
Hello Simon,

Thank you for the report.

Thanks,
Umesh
[7 May 2015 16:23] Paul Dubois
Noted in 5.7.8, 5.8.0 changelogs.

The shutdown timeout value in /etc/init.d/mysqld was too short for 
some environments. The value has been increased from 60 seconds to
600 seconds.
[8 May 2015 8:23] Simon Mudd
Many thanks.