I'm running Percona MySQL server 5.6 (from packages) on debian wheezy (same behavior on jessie). Unfortunately I always get this:
# service mysql stop
[FAIL] Stopping MySQL (Percona Server): mysqld failed!
I can say about my configuration that
- /etc/init.d/mysql is untouched
- /etc/mysql/debian.cnf contains valid and working (tested) credentials for debian-sys-maint
I investigated the the init script a little bit more and came to the conclusion that the problem seems to be mysqladmin.
The init script calls
mysqladmin --defaults-file=/etc/mysql/debian.cnf shutdown
After mysqladmin returns, it checks whether the server has been properly shut down. Now this seems to be the problem: mysqladmin returns BEFORE it has been shut down completely and then checks TOO EARLY that it is still running.
I was also watching the log files while investigating this. My finding:
2017-01-05 00:18:49 12595 [Note] InnoDB: Starting shutdown...
2017-01-05 00:18:49 7f70e4df7700 InnoDB: Dumping buffer pool(s) to .//ib_buffer_pool
2017-01-05 00:18:49 7f70e4df7700 InnoDB: Buffer pool(s) dump completed at 170105 0:18:49
2017-01-05 00:18:49 12595 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
This is the moment mysqladmin returns. Still it continues:
2017-01-05 00:18:51 12595 [Note] InnoDB: Shutdown completed; log sequence number 120471740085
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'ARCHIVE'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'MyISAM'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'MEMORY'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'CSV'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'MRG_MYISAM'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'sha256_password'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'mysql_old_password'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'mysql_native_password'
2017-01-05 00:18:51 12595 [Note] Shutting down plugin 'binlog'
2017-01-05 00:18:51 12595 [Note] /usr/sbin/mysqld: Shutdown complete
Proof: I added "sleep 5" in my init script after the shutdown to delay the check - works.
Now my 2 questions: 1. Is the debian init script broken at this point? 2. Is there a way to configure the server in a way that mysqladmin will wait for the full shutdown?
I came across a similar issue but with mysql 5.7, the issue I thought would would be, is MySQL not honouring the default shutdown-timeout of 3600 seconds . So when I used the following shutdown command the mysqladmin waited until the shutdown process completed successfully.
Added on 12-Mar-2019:
Mostly the issue was due to the following bug https://bugs.mysql.com/bug.php?id=91803 . After the addition of pid-file in my.cnf, the mysqladmin is waiting for the shutdown process to complete