Bug #17893 MySQL fails to report when service initialization fails
Submitted: 3 Mar 2006 10:33 Modified: 8 Apr 2009 15:42
Reporter: d di (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.20a, 5.0.18 OS:Windows (Windows)
Assigned to: Sergei Glukhov CPU Architecture:Any
Tags: qc

[3 Mar 2006 10:33] d di
Description:
When run as a service, MySQL randomly fails to report the correct status to the Service Control Manager.

How to repeat:
First, we'll simulate a MySQL failure during startup.  We can do that by faking the base directory in my.ini.  Just entering any non-existing directory should do.

Then type the following into a BAT file:
REM ==========================
:X
NET START MYSQL
GOTO X
REM ==========================

Start the BAT file with this command:
C:\> whatever.bat >>log.txt 2>&1

Let it run for a while.

You should see the following entry at some point in your log file:
==========================
C:\> NET START MYSQL
The MySQL service is starting.
The MySQL service could not be started.

A system error has occurred.
System error 1067 has occurred.
The process terminated unexpectedly.
==========================

In other places, you should see the following entry:
==========================
C:\> NET START MYSQL

The MySQL service was started successfully.
==========================

Although the MySQL service will of course _not_ have started successfully since the basedir does not exist.

Since this behaviour seems sporadic, this issue is probably timing related - you might have to try different PCs to experience this.

Suggested fix:
Instead of randomly doing one of the following:
 * setting service status to RUNNING
 * terminating the service process

MySQL should wait until initialized (when "ready for connections" is written to it's log) and then set the service status to RUNNING.

When initialization is /not/ successful, MySQL should report STOPPED along with an error, for example 1066 (service specific error) with an additional MySQL error code that the user can look up.  The MySQL specific error could be a static error code that always resolves to "look in the event log or error log file" when looked up by perror or in the manual.
[27 Apr 2006 11:57] Valeriy Kravchuk
Verified just as described with latest 5.0.20a on XP. 

I used .bat file like those presented. "Successful" start was reported at the third attempt of start. I was not able to repeat by starting "manually", with longer delays among "net start" commands.
[8 Apr 2009 15:41] Vladislav Vaintroub
This is fixed with Bug#20430
[8 Apr 2009 15:41] Vladislav Vaintroub
This is fixed with Bug#20430