mirror of
https://github.com/MariaDB/server.git
synced 2026-05-02 21:25:36 +02:00
Bug #20430 mysqld.exe windows service stuck in "SERVICE_STOP_PENDING"
status The problem appears to be a race condition, when service is being stopped right after startup. We set the service status to SERVICE_RUNNING way too early it cannot yet handle stop requests - initialization has not finished and hEventShutdown that signals server to stop is not yet created. If somebody issues "net stop MySQL" at this time, MySQL is not informed about the stop and continues to run as usual, while NTService::ServiceMain() stucks forever waiting for mysql's "main" thread to finish. Solution is to remain in SERVICE_START_PENDING status until after server initialization is fully complete and only then change the status to SERVICE_RUNNING. In SERVICE_START_PENDING we do not accept service control requests, i.e it is not possible to stop service in that time. sql/mysqld.cc: Set service status to running after all initialization is complete sql/nt_servc.cc: New method SetRunning() to be called by application to set service status to SERVICE_RUNNING when apllication has finished initialization. sql/nt_servc.h: New method SetRunning() to be called by application when initialization completes
This commit is contained in:
parent
60d5e90089
commit
f2a610e1e0
3 changed files with 24 additions and 5 deletions
|
|
@ -245,10 +245,6 @@ void NTService::ServiceMain(DWORD argc, LPTSTR *argv)
|
|||
if (!pService->StartService())
|
||||
goto error;
|
||||
|
||||
// Check that the service is now running.
|
||||
if (!pService->SetStatus(SERVICE_RUNNING,NO_ERROR, 0, 0, 0))
|
||||
goto error;
|
||||
|
||||
// wait for exit event
|
||||
WaitForSingleObject (pService->hExitEvent, INFINITE);
|
||||
|
||||
|
|
@ -264,6 +260,14 @@ error:
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
void NTService::SetRunning()
|
||||
{
|
||||
if (pService)
|
||||
pService->SetStatus(SERVICE_RUNNING,NO_ERROR, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
StartService() - starts the appliaction thread
|
||||
-------------------------------------------------------------------------- */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue