grate: Regression in v1.4

Our CI on an existing grate project has started failing, the final green build was on V1.3.2, the first failed build was V1.4, and it has failed every run subsequent.

This migration is targeting a localdb sql instance. Script to run the CI migration is:

dotnet tool update grate -g

grate `
--files=../db `
--env=IntegrationTest `
--connstring="Server=(localdb)\MSSQLLocalDB;Integrated Security=true;Database=MyApp_IntegrationTest;Application Name=grate" `
--version=1.0 `
--silent `
--drop

Updating the deployment script to force install V1.3.2 lets the migration complete successfully again, ie replace the update command with:

dotnet tool uninstall grate -g
dotnet tool install grate -g --version 1.3.2

and it works fine again.

To Reproduce Failure is a SQL Timeout while running a runAfterCreateDatabase script to enable RCSI, script content is:

ALTER DATABASE {{DatabaseName}} SET ALLOW_SNAPSHOT_ISOLATION ON
ALTER DATABASE {{DatabaseName}} SET READ_COMMITTED_SNAPSHOT ON

** AzDo Output (slightly elided for confidentiality) **

Starting: Deploy Database for Integration Tests
    ==============================================================================
    Task         : PowerShell
    Description  : Run a PowerShell script on Linux, macOS, or Windows
    Version      : 2.200.0
    Author       : Microsoft Corporation
    Help         : []
    ==============================================================================
    Generating script.
    Formatted command: . 'D:\a\1\s\src\MyApp.Database\deployment\init_test_database.ps1'
    ========================== Starting Command Output ===========================
    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a\_temp\a9125961-11eb-4d77-811c-38ee4104f896.ps1'"
    You can invoke the tool using the following command: grate
    Tool 'grate' (version '1.4.0') was successfully installed.
    Initializing connections.
    Running grate v1.4.0.0 against (localdb)\MSSQLLocalDB - MyApp_IntegrationTest.
    Looking in ../db for scripts to run.
    ================================================================================
    Setup, Backup, Create/Restore/Drop
    ================================================================================
    grate has removed database (MyApp_IntegrationTest) if it existed.
    ================================================================================
    Grate Structure
    ================================================================================
    ================================================================================
    Versioning
    ================================================================================
     Migrating MyApp_IntegrationTest from version 0.0.0.0 to 1.0.
     Versioning MyApp_IntegrationTest database with version 1.0.
    ================================================================================
    Migration Scripts
    ================================================================================
    Skipping 'BeforeMigration', beforeMigration does not exist.
    Skipping 'AlterDatabase', alterDatabase does not exist.
                                                                                    
    Looking for Run After Create Database scripts in "../db\runAfterCreateDatabase".
    --------------------------------------------------------------------------------
      Running '001-RCSI.sql'.
    Error running script "001-RCSI.sql": Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
                                                                                    
    Looking for Permissions scripts in "../db\permissions". These scripts will run every time.
    --------------------------------------------------------------------------------
      Running 'RmtTVP.sql'.
    Error running script "RmtTVP.sql": Cannot find the type 'MediaTVP', because it does not exist or you do not have permission.
    Cannot find the object 'ProjectMedia', because it does not exist or you do not have permission.
    Cannot find the object 'ChildMedia', because it does not exist or you do not have permission.
    Skipping 'AfterMigration', afterMigration does not exist.
    Unhandled exception: grate.Exceptions.MigrationFailed: Migration failed due to errors:
     * Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
     * Cannot find the type 'MediaTVP', because it does not exist or you do not have permission.
    Cannot find the object 'ProjectMedia', because it does not exist or you do not have permission.
    Cannot find the object 'ChildMedia', because it does not exist or you do not have permission.
     ---> 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 (258): The wait operation timed out.
       at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at Microsoft.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(Boolean callerHasConnectionLock, Boolean asyncClose)
       at Microsoft.Data.SqlClient.TdsParserStateObject.CheckThrowSNIException()

Interestingly it continues on after the timeout, the timeout doesn’t produce a stacktrace, but the following steps do?

Desktop (please complete the following information):

  • OS: Windows 11
  • Version 22000.856

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Hey mate, nice catch.

I can confirm that adding pooling=false fixed the first of my real world projects, both the integration tests looking at localdb like the example above, and my dev Sql 2019 database running in docker.

I think you’re onto something here… Looks like there was a few transaction related bugs fixed between 5 and 5.0.2, hopefully this was one of them.