Skip to content

Slow/inconsistent startup time for SQL Server LocalDB on windows-2022 image #8164

@cremor

Description

@cremor

Description

I’m running database integration tests in Azure DevOps Pipelines with the Microsoft-hosted Windows agent. The tests use MS SQL Server Express LocalDB. The time it takes to start the LocalDB instance is very inconsistent. Sometimes it takes just 20 seconds (which is still slow compared to my local dev machine), but sometimes it takes more than 5 minutes!

For that reason I can’t just use LocalDB in my tests and rely on automatic startup of the DB like I’m used to from my local dev machine because then the tests time out.
As a workaround I now have an explicit step in my pipeline:

- script: 'sqllocaldb start MSSQLLocalDB'
  displayName: 'Start SQL Server LocalDB'

The works most of the time, but as mentioned just this single command can take multiple minutes.

Rarely the LocalDB startup even fails. It then prints the following to the log:

Start of LocalDB instance "MSSQLLocalDB" failed because of the following error:
Cannot create an automatic instance. See the Windows Application event log for error details.

(I can't check the Windows Application event log for details because this is a Microsoft-hosted agent. Enabling system diagnostics for the build also doesn't provide any more useful logs.)

Please fix this so that the LocalDB startup is consistently fast.
Maybe it would be possible to already start it when the image is created so that each new build run already gets a started LocalDB instance?

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 11
  • macOS 12
  • macOS 13
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Image: windows-2022
Version: 20230804.1.0

Is it regression?

unknown

Expected behavior

MS SQL Server Express LocalDB creation/startup time should be fast and consistent.
Ideally I could rely on the auto-start feature and not have to manually start the LocalDB with a script step.

Actual behavior

MS SQL Server Express LocalDB creation/startup time varies between a few seconds and multiple minutes.

Repro steps

  1. Create a pipeline which includes this step:
- script: 'sqllocaldb start MSSQLLocalDB'
  displayName: 'Start SQL Server LocalDB'
  1. Run the pipeline multiple times and observe the time it takes to execute the step.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions