Bug #45546 Start windows service, then execute what is needed.
Submitted: 17 Jun 2009 5:19 Modified: 15 Dec 2011 18:41
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Windows Severity:S2 (Serious)
Version: OS:Windows
Assigned to: CPU Architecture:Any

[17 Jun 2009 5:19] Roel Van de Paar
o Windows only waits about 30 seconds for a service to start.
o InnoDB startup may take more.

C:\mysql5.1.35>net start mysql5135
The mysql5135 service is starting....................
The mysql5135 service could not be started.

More help is available by typing NET HELPMSG 3523.

C:\mysql5.1.35>net helpmsg 3523

The *** service could not be started.

How to repeat:
o Clean mysql with no ib* files
o Use innodb_data_file_path=ibdata1:6G;ibdata2:6G:autoextend in my.ini
o Start service

Unless you have a fast machine, this will show the issue.

Suggested fix:
Start the service first, then execute what is needed.

Or, possibly better, use SetServiceStatus (http://msdn.microsoft.com/en-us/library/ms686241.aspx) regularly to tell Windows that the service is still starting normally:

'During initialization, the service can provide updated status to indicate that it is making progress but it needs more time.'

Also see the URL above for gotchas ('A common bug is for the service to have the main thread perform the initialization while a separate thread continues to call SetServiceStatus to prevent the service control manager from marking it as hung. However, if the main thread hangs, then the service start ends up in an infinite loop because the worker thread continues to report that the main thread is making progress.')
[17 Jun 2009 5:48] Sveta Smirnova
Potentially can lead to same problem as in bug #41908
[17 Jun 2009 19:43] Valeriy Kravchuk
Windows should not let to start service that is already started/is in the process of starting.

I think this is a reasonable feature request.
[12 Oct 2009 2:02] Roel Van de Paar
If the server is slow in shutting down, possibly the same issue may happen during shutdown. 

Workaround: use:

shell> SC INTERROGATE <service_name> | FIND "STATE" 

To check if the service has successfully started/stopped. Example:

C:\>NET START mysql5137
The mysql5137 service is starting.
The mysql5137 service was started successfully.

        STATE              : 4  RUNNING

C:\>NET STOP mysql5137
The mysql5137 service is stopping.
The mysql5137 service was stopped successfully.


[15 Dec 2011 18:41] Paul DuBois
Noted in 5.5.20, 5.6.5 changelogs.

A new server option, --slow-start-timeout, controls the Windows
service control manager's service start timeout. The value is the
maximum number of milliseconds that the service control manager waits
before trying to kill the MySQL service during startup. The default 
value is 15000 (15 seconds). If the MySQL service takes too long to
start, you may need to increase this value. A value of 0 means there
is no timeout.