Closed Barsonax closed 5 years ago
Copied from @joostmeijles post (might fix the second error?):
Probably need to add to xp/mssql/Boot.ps1
, something like:
USE master;
GO
ALTER DATABASE AdventureWorks2012
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE AdventureWorks2012
SET READ_ONLY;
GO
ALTER DATABASE AdventureWorks2012
SET MULTI_USER;
GO
First error could be fixed by first checking if the mssql service is running
(GET-SERVICE MSSQLSERVER).Status -eq 'Running'
If its not then sleep for a bit and check again before running the queries.
Alternatively we could start the service ourselves instead of relying on the automatic service.
# Make sure SQL server is running
Start-Service MSSQLSERVER;
(Get-Service MSSQLSERVER).WaitForStatus('Running');
Could possibly be a race condition in the container?
However there seems to be more flavors of this boot error:
Another error that can occur even if the sql server is already started:
Another one in the repair query:
Goal is to fix all possible startup errors to make the mssql container more robust.