From dd986ee84c97a7aa52e1d48ee3c1d0b45833d767 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Thu, 11 Aug 2022 17:24:49 -0700 Subject: [PATCH] Add a delay to avoid race condition for generate script to new Azure db (#1629) --- .../DacFx/GenerateDeployScriptOperation.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs b/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs index 5089168f..25187aca 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/DacFx/GenerateDeployScriptOperation.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // using System.IO; +using System.Threading; using Microsoft.SqlServer.Dac; using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.DacFx.Contracts; @@ -51,6 +52,9 @@ namespace Microsoft.SqlTools.ServiceLayer.DacFx this.SqlTask.AddScript(SqlTaskStatus.Succeeded, Result.DatabaseScript); if (!string.IsNullOrEmpty(this.Result.MasterDbScript)) { + // Delay to avoid race condition to ensure both scripts get opened in ADS. Fix for https://github.com/microsoft/azuredatastudio/issues/20133 + Thread.Sleep(500); + // master script is only used if the target is Azure SQL db and the script contains all operations that must be done against the master database this.SqlTask.AddScript(SqlTaskStatus.Succeeded, this.Result.MasterDbScript); }