I'm trying to do a release of our web app (using tfs to deploy to Azure), but I keep getting an error that I can't make any sense of:
2018-07-10T07:07:27.7518609Z RoundhousE encountered an error. You were running in a transaction though, so the database should be in the state it was in prior to this piece running. This does not include a drop/create or any creation of a database, as those items can not run in a transaction.
2018-07-10T07:07:27.7520033Z System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable.
2018-07-10T07:07:27.7520928Z at System.Data.SqlClient.SqlTransaction.ZombieCheck()
2018-07-10T07:07:27.7521739Z at System.Data.SqlClient.SqlTransaction.Rollback()
2018-07-10T07:07:27.7522799Z at roundhouse.databases.AdoNetDatabase.rollback()
2018-07-10T07:07:27.7523835Z at roundhouse.migrators.DefaultDatabaseMigrator.run_sql(String sql_to_run, String script_name, Boolean run_this_script_once, Boolean run_this_script_every_time, Int64 version_id, EnvironmentSet environment_set, String repository_version, String repository_path, ConnectionType connection_type)
2018-07-10T07:07:27.7525261Z at roundhouse.runners.RoundhouseMigrationRunner.traverse_files_and_run_sql(String directory, Int64 version_id, MigrationsFolder migration_folder, EnvironmentSet migrating_environment_set, String repository_version, ConnectionType connection_type)
2018-07-10T07:07:27.7526355Z at roundhouse.runners.RoundhouseMigrationRunner.log_and_traverse(MigrationsFolder folder, Int64 version_id, String new_version, ConnectionType connection_type)
2018-07-10T07:07:27.7527288Z at roundhouse.runners.RoundhouseMigrationRunner.run()
2018-07-10T07:07:27.7535389Z This SqlTransaction has completed; it is no longer usable.
2018-07-10T07:07:27.7536462Z System.InvalidOperationException: This SqlTransaction has completed; it is no longer usable.
2018-07-10T07:07:27.7537385Z at System.Data.SqlClient.SqlTransaction.ZombieCheck()
2018-07-10T07:07:27.7538815Z at System.Data.SqlClient.SqlTransaction.Rollback()
2018-07-10T07:07:27.7539676Z at roundhouse.databases.AdoNetDatabase.rollback()
2018-07-10T07:07:27.7540661Z at roundhouse.migrators.DefaultDatabaseMigrator.run_sql(String sql_to_run, String script_name, Boolean run_this_script_once, Boolean run_this_script_every_time, Int64 version_id, EnvironmentSet environment_set, String repository_version, String repository_path, ConnectionType connection_type)
2018-07-10T07:07:27.7541750Z at roundhouse.runners.RoundhouseMigrationRunner.traverse_files_and_run_sql(String directory, Int64 version_id, MigrationsFolder migration_folder, EnvironmentSet migrating_environment_set, String repository_version, ConnectionType connection_type)
2018-07-10T07:07:27.7542995Z at roundhouse.runners.RoundhouseMigrationRunner.log_and_traverse(MigrationsFolder folder, Int64 version_id, String new_version, ConnectionType connection_type)
2018-07-10T07:07:27.7543950Z at roundhouse.runners.RoundhouseMigrationRunner.run()
2018-07-10T07:07:27.7544856Z at roundhouse.console.Program.run_migrator(ConfigurationPropertyHolder configuration)
2018-07-10T07:07:27.7545759Z at roundhouse.console.Program.Main(String[] args)
2018-07-10T07:07:29.8091395Z ##[error]Process completed with exit code 1.
This never happened when deploying locally or to our demo environment. This always happens when trying to execute the same simple SQL script, which is the fifth one that needs to be run. The script runs fine from SSMS against a copy of the production database, but it takes upwards of 10 minutes to complete. At first I thought roundhousE might be timing out, but I tried setting the timeout much higher and it had no effect.
Does anyone have any insight on what is going on here?
Here's the script, if that helps:
UPDATE ut
SET ut.IsX = t.IsX
FROM UserTasks ut
INNER JOIN Procedures p
ON ut.ProcedureID = p.ID
INNER JOIN Types t
ON p.TypeID = t.ID;
It looks like my original intuition was correct, and the issue was caused by the query timing out.
I had edited the timeout length in our build script, but forgot that tfs calls roundhousE directly, and didn't change the length there. Doing so resolved the issue.