microsoft / microsoft/DacFx

SqlPackage Import fails with timeout when enabling triggers

Open
#93 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
460
Forks
29
Avg merge
4d 9h
Merged PRs (30d)
7

Description

- SqlPackage or DacFx Version: 16.0.5400.1
- .NET Framework (Windows-only) or .NET Core: 4.7.02053
- Environment (local platform and source/target platforms): Windows Server 2019 Standard, SQL Server 2017, Azure SQL Database

**Steps to Reproduce:**

1. Export database with SqlPackage to bacpac file
2. Import database with SqlPackage into Azure SQL Database Elastic Pool (Gen5 8 vCores)
3. Import runs and completes processing tables and enables indexes
4. Timeout when enabling triggers as follows:

```
Microsoft.Data.Tools.Diagnostics.Tracer Verbose: 0 : 2022-04-21T21:01:42 : Executing Step 1492, Not Tracked, Type 'EnableDmlTriggersStep', Section 'None', Operation '0', Ignorable Errors 'None', Script is as follows:

ENABLE TRIGGER [dbo].[trig_Search_Specification]
ON [dbo].[tbl_Company_Specification];

Microsoft.Data.Tools.Diagnostics.Tracer Error: 19 : 2022-04-21T21:02:12 : Retry requested: Retry count = 1. Delay = 00:00:00.2500000, SQL Error Code = -2146232060, SQL Error Number = -2, Can retry error = True, Will retry = True Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at Microsoft.Data.SqlClient.SqlCommand.<>c.b__243_0()
at Microsoft.Data.SqlClient.AsyncHelper.WaitForCompletion(Task task, Int32 timeout, Action onTimeout, Boolean rethrowExceptions)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.QuerySessionSettings(IDbCommand originalCommand)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.CacheOrReplaySessionSettings(IDbCommand originalCommand, Tuple`2[] sessionSettings)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.<>c__DisplayClass2.b__1()
at Microsoft.Data.Tools.Schema.Common.SqlClient.RetryPolicy.ExecuteAction[R](Func`2 func, Nullable`1 token)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-2,State:0,Class:11
Microsoft.Data.Tools.Diagnostics.Tracer Warning: 0 : 2022-04-21T21:02:12 : Retry occurred: session: 77dffe89-d0f0-4047-8f47-27c9e1095d13; attempt - 1; delay - 00:00:00.2500000; exception - "Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at Microsoft.Data.SqlClient.SqlCommand.<>c.b__243_0()
at Microsoft.Data.SqlClient.AsyncHelper.WaitForCompletion(Task task, Int32 timeout, Action onTimeout, Boolean rethrowExceptions)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.QuerySessionSettings(IDbCommand originalCommand)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.CacheOrReplaySessionSettings(IDbCommand originalCommand, Tuple`2[] sessionSettings)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.<>c__DisplayClass2.b__1()
at Microsoft.Data.Tools.Schema.Common.SqlClient.RetryPolicy.ExecuteAction[R](Func`2 func, Nullable`1 token)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-2,State:0,Class:11"
Microsoft.Data.Tools.Diagnostics.Tracer Error: 19 : 2022-04-21T21:02:12 : Retry requested: Retry count = 1. Delay = 00:00:00.2500000, SQL Error Code = -2146232060, SQL Error Number = -2, Can retry error = True, Will retry = True Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at Microsoft.Data.SqlClient.SqlCommand.<>c.b__243_0()
at Microsoft.Data.SqlClient.AsyncHelper.WaitForCompletion(Task task, Int32 timeout, Action onTimeout, Boolean rethrowExceptions)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.QuerySessionSettings(IDbCommand originalCommand)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.CacheOrReplaySessionSettings(IDbCommand originalCommand, Tuple`2[] sessionSettings)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.<>c__DisplayClass5.b__4()
at Microsoft.Data.Tools.Schema.Common.SqlClient.RetryPolicy.ExecuteAction[R](Func`2 func, Nullable`1 token)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-2,State:0,Class:11
Microsoft.Data.Tools.Diagnostics.Tracer Warning: 0 : 2022-04-21T21:02:12 : Retry occurred: session: 77dffe89-d0f0-4047-8f47-27c9e1095d13; attempt - 1; delay - 00:00:00.2500000; exception - "Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at Microsoft.Data.SqlClient.SqlCommand.<>c.b__243_0()
at Microsoft.Data.SqlClient.AsyncHelper.WaitForCompletion(Task task, Int32 timeout, Action onTimeout, Boolean rethrowExceptions)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.QuerySessionSettings(IDbCommand originalCommand)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.CacheOrReplaySessionSettings(IDbCommand originalCommand, Tuple`2[] sessionSettings)
at Microsoft.Data.Tools.Schema.Common.SqlClient.ReliableSqlConnection.<>c__DisplayClass5.b__4()
at Microsoft.Data.Tools.Schema.Common.SqlClient.RetryPolicy.ExecuteAction[R](Func`2 func, Nullable`1 token)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:-2,State:0,Class:11"
```
etc.

Post failure the trigger can be enabled in SSMS with no issue via the context menu or executing the `ENABLE TRIGGER` directly.

Intervening during the retry sequence and enabling the trigger does not affect the outcome, the retry loop continues with eventual failure of the import.

**Did this occur in prior versions? If not - which version(s) did it work in?**
Unknown

(DacFx/SqlPackage/SSMS/Azure Data Studio)

Contributor guide

Open the contributing guide

Research direction

Start with the reported SqlPackage import into an Azure SQL Database Elastic Pool and the logged EnableDmlTriggersStep for ENABLE TRIGGER. Compare the failing import behavior with enabling the same trigger in SSMS or by direct SQL execution, and inspect the retry sequence. Done means the import completes and the trigger is enabled without the timeout failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp, sql
Domain
cloud, databases, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.