mattiasnordqvist / Galactic-Waste-Management

The best SQL Server migration tool I've found so far
2 stars 1 forks source link

Issues with connection disposal #45

Open carl-berg opened 4 years ago

carl-berg commented 4 years ago

A few times we've run into an issue where GWM fails to migrate up in azure:

2019-11-20T09:49:49.1020681Z  #### GALACTIC WASTE MANAGER ENGAGED #### 
2019-11-20T09:49:49.1028816Z Managing galactic waste in MyDB
2019-11-20T09:49:49.1034888Z Running LiveField mode
2019-11-20T09:49:51.2208092Z Found changed or added RunIfChanged-scripts.
2019-11-20T09:49:51.2414726Z Executing script 'MyNamespace.Scripts.RunIfChanged.CreateSynchronizeInvoiceRowView.sql'
2019-11-20T09:49:52.7427982Z This SqlTransaction has completed; it is no longer usable.

Unhandled Exception:
System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable.
   at System.Data.SqlClient.SqlTransaction.ZombieCheck()
   at System.Data.SqlClient.SqlTransaction.Commit()
   at JellyDust.Transaction.Commit()
   at GalacticWasteManagement.TransactionManager.Dispose()
   at GalacticWasteManagement.MigrationBase.ManageGalacticWaste()
   at GalacticWasteManagement.GalacticWasteManager.Update(Func`2 migratorFactory, Dictionary`2 parameters, Dictionary`2 scriptVariables)
   at GalacticWasteManagement.GalacticWasteManager.Update(String mode, Dictionary`2 parameters, Dictionary`2 scriptVariables)
   at Envirotainer.Portal.Financials.Migration.Runner.Program.<Main>(String[] args)
PowerShell exited with code '1'.

also when digging into this i found that TransactionManager.singleTransaction gets initialized with Parameters.Optional(new InputBool("transaction-per-script", ""), false) which seems seem wrong? I don't know if it's related at all but maybe something that can be looked into.

carl-berg commented 4 years ago

Seems like the issue might have been an issue with the sql inside the script but this was the resulting error which could be confusing

mattiasnordqvist commented 4 years ago

What do you think is wrong with transactionManager.singleTransaction getting initialized with Parameters.Optional(new InputBool("transaction-per-script", ""), false)?

mattiasnordqvist commented 4 years ago

Ah now I see! 😅

mattiasnordqvist commented 4 years ago

looks ok? https://github.com/mattiasnordqvist/Galactic-Waste-Management/commit/ccd3802c156947d7564bb08da315cec9ee6e5c87 @carl-berg

carl-berg commented 4 years ago

Looks good!

Any idea on the other issue with This SqlTransaction has completed; it is no longer usable. exception when running bad sql?

mattiasnordqvist commented 4 years ago

I'll look into it someday!