Skip to main content
Delphix

Resolving "database already exists" error during SQL Server VDB operations (KBA7712)

 

KBA

KBA# 7712

 

Issue

When attempting to perform VDB operations on SQL Server VDBs, including Enable, Start, or Disable, a "database already exists" warning or error may appear:

Error: Failed to perform operation on VDB "MyDatabase" because a database with  name "MyDatabase", primary data file "C:\temp\data.mdf" already exists on instance "SQL2016", host environment "mysqlservertarget.mydomain.com" and is not managed by Delphix.

Error Code: exception.db.mssqlvdb.vdb.target_db.different

Suggested Action: Detach the existing database from within SQL Server and try this operation again, or use the Delphix Engine Migrate function to move this VDB to a different SQL Server instance.

There are several reasons that this issue may occur, including:

  1. A local database with the same name has been attached to the Target Database Instance;
  2. A VDB with the same name has been provisioned from a different Delphix Engine; or
  3. An uncontrolled Replication Failover has recently occurred between Delphix Engines.

The resolution steps below describe how to identify and respond to the above situations.

Applicable Delphix Versions

Click here to view the versions of the Delphix engine to which this article applies
Major Release All Sub Releases
6.0 6.0.0.0, 6.0.1.0, 6.0.1.1, 6.0.2.0, 6.0.2.1, 6.0.3.0, 6.0.3.1, 6.0.4.0, 6.0.4.1, 6.0.4.2, 6.0.5.0, 6.0.6.0, 6.0.6.1, 6.0.7.0, 6.0.8.0, 6.0.8.1

5.3

5.3.0.0, 5.3.0.1, 5.3.0.2, 5.3.0.3, 5.3.1.0, 5.3.1.1, 5.3.1.2, 5.3.2.0, 5.3.3.0, 5.3.3.1, 5.3.4.0, 5.3.5.0, 5.3.6.0, 5.3.7.0, 5.3.7.1, 5.3.8.0, 5.3.8.1, 5.3.9.0

5.2

5.2.2.0, 5.2.2.1, 5.2.3.0, 5.2.4.0, 5.2.5.0, 5.2.5.1, 5.2.6.0, 5.2.6.1

5.1

5.1.0.0, 5.1.1.0, 5.1.2.0, 5.1.3.0, 5.1.4.0, 5.1.5.0, 5.1.5.1, 5.1.6.0, 5.1.7.0, 5.1.8.0, 5.1.8.1, 5.1.9.0, 5.1.10.0

5.0

5.0.1.0, 5.0.1.1, 5.0.2.0, 5.0.2.1, 5.0.2.2, 5.0.2.3, 5.0.3.0, 5.0.3.1, 5.0.4.0, 5.0.4.1, 5.0.5.0, 5.0.5.1, 5.0.5.2, 5.0.5.3, 5.0.5.4

Resolution when the VDB has been replaced with a local database

The details of the affected instance are shown in the error message, as well as in the Configuration → Source tab of the Manage → Datasets screen.

To confirm that the database has been replaced, you can use SQL Server Management Studio to connect to the affected SQL Server instance, and check the Properties of the database.

In the below example, the MyDatabase database shows that its data files exist on the instance's local storage, in this case C:\temp:

clipboard_e7773a32e7e33c0f282d379c326fe5524.png

There may be valid business reasons that the VDB has been replaced with a physical copy of the database.

If it is important to keep the current database online, you can leave the VDB disabled. It can be re-enabled once the local copy is no longer present.

If the local copy of the database is no longer required, and you wish to use this Delphix Engine VDB instead, complete the following steps:

  1. From the Manage → Datasets screen, Disable the VDB from the Ellipsis (...) menu, if this has not already been done. This may raise a warning, which is expected.
  2. Use SQL Server Management Studio to detach or rename the conflicting local database. This will ensure that the existing database files are not deleted, in case this data is needed later.
  3. From the Manage → Datasets screen, Enable the VDB using the Ellipsis (...) menu.

This operation should complete successfully, and VDB operations (including Snapshot, Refresh, Stop and Start) should now function normally.

Resolution when VDB has been provisioned from another engine

In some cases, the error message may reference data files in a Delphix Connector directory instead of local database files:

Failed to perform operation on VDB "MyDatabase" because a database with name "MyDatabase", primary data file "C:\DelphixConnector\564d84e7-39b6-afbf-015f-0676ec9c9758-vdb-2\DATA\db\data.mdf" already exists on instance "SQL2016", host environment "mysqlservertarget.mydomain.com" and is not managed by Delphix.

The reported Delphix Connector directory in this error will include a UUID, such as 564d84e7-39b6-afbf-015f-0676ec9c9758.

If the conflicting VDB has been provisioned from another Delphix Engine, this UUID will not match the Server ID listed in the Delphix Engine's Help → About dialog:

Server ID: 564d759c-fa8e-890e-7622-01465c85734d

In this case, it will be necessary to determine which of the two VDBs is the most appropriate for your environment. The less relevant VDB should be disabled, renamed, or deleted as appropriate, using the Management interface of that Delphix Engine.

The Delphix Engine raising this error will not determine which other Delphix Engine in your environment is presenting the conflicting VDB. It may be necessary to check the Server ID of other Delphix Engines in your environment to find the one which manages the conflicting VDB.

Resolution after an uncontrolled Delphix Engine failover

If a Delphix Engine failover has occurred and the databases have not been cleanly disabled as described in the document Controlled Failover, an Uncontrolled Failover occurs.

In this case, VDBs may fail to enable, reporting an error that references a Delphix Connector subdirectory:

Failed to perform operation on VDB "MyDatabase" because a database with name "MyDatabase", primary data file "C:\DelphixConnector\564d84e7-39b6-afbf-015f-0676ec9c9758-vdb-2\DATA\db\data.mdf" already exists on instance "SQL2016", host environment "mysqlservertarget.mydomain.com" and is not managed by Delphix.

This error message will include a UUID, such as 564d84e7-39b6-afbf-015f-0676ec9c9758 in the example above, and it will not match the Server ID listed in the Help → About dialog of the Delphix Engine. Instead, it will correspond to the Server ID of the engine from which failover has taken place.

In this case, follow the appropriate SQL Server procedures in the Delphix Engine document Uncontrolled Failover.

Related Articles

The following articles may provide more information or related information to this article: