SQL Automation Pack

SQL LocalDB instance RedGateTemp corrupted

If you're using SQL CI and see the error:

sqlCI error occurred: System.InvalidOperationException: The SQL LocalDB instance 'RedGateTemp' does not exist.

Your RedGateTemp instance may be corrupt. This is a known issue with LocalDB. To work around this, see details below on Fixing a corrupt RedGateTemp instance.

If you see the error:

'Starting LocalDB failed with error: Could not start LocalDB: Error occurred during LocalDB instance startup: SQL Server process failed to start.|r|n. Ensure that localDB is installed and that it is possible to start the default instance using the command |'sqllocaldb start v11.0|', or specify a different temporary database server by setting the option |'temporaryDatabaseServer|'

Either your RedGateTemp instance may be corrupt (see details below on Fixing a corrupt RedGateTemp instance), or you don't have LocalDB installed. To install LocalDB, do one of the following:

  • Install the version of SQL CI included in SQL Automation Pack versions 1.1.1.1950 and later. If you're machine has an internet connection, this installs LocalDB automatically. See Installing SQL CI
  • Install LocalDB manually. See SQL LocalDB

Fixing a corrupt RedGateTemp instance

Check the Services Microsoft Management Console (MMC) to find out which account your CI server build agent is running under. 

  1. In the Windows Start menu, enter services.msc.
  2. Find your CI server build agent service and check the entry in the Log On As column. In this example, the TeamCity build agent is running under Local System:

Use Microsoft's PsExec tools to log in to the correct account for your build agent.

  1. Download and unzip PsTools, which contains PsExec. See PsExec.
  2. Open an elevated command prompt. To do this, in the Windows Start menu, type cmd, right-click on the command prompt program and select Run as administrator.
  3. Using the command prompt, navigate to the PsExec download location.
  4. Enter one of the following commands, depending on which account you need to run to configure the build agent:
    • For Local System, enter psexec -i -s cmd.exe 
    • For Local Service, enter psexec -u "nt authority\Local Service" cmd.exe
    • For other accounts or for more information about using PsExec, see Using PsExec
    A new command prompt is displayed. You should be logged in to the correct account for your build agent. To check this, enter whoami

Check whether you can access the RedGateTemp instance created by SQL CI. If you can't, the instance is corrupt and you'll need to delete it. 

  1. At the command prompt, enter SqlLocalDB.exe info RedGateTemp
    If an error message is displayed containing LocalDB instance "RedGateTemp" is corrupted!, delete the instance. 

  2. Enter SqlLocalDB.exe delete RedGateTemp

  3. Enter SqlLocalDB.exe info to display a list of instances. Check that the RedGateTemp instance no longer exists. 

You can now rerun the build step. The instance should be created automatically without corruption errors.

If you're still experiencing issues with LocalDB, contact support@red-gate.com

 


Didn't find what you were looking for?