Evolve icon indicating copy to clipboard operation
Evolve copied to clipboard

Error trying to release Evolve lock

Open CanIGetaPR opened this issue 3 years ago • 1 comments

Evolve C# Library 3.0.0 from nuget MySQL InnoDB database. .NET 5

Issue started when I tried adding migrations. Last time I had successful migrations was in 2019. I've upgraded .NET since then. My Evolve was version 2.4.x and I just tried upgrading to 3.0.0 to fix these problems doing migrations. I tried adding the CommandTimeout config just now in case it's timing out. No luck to 3.0.0 or CommandTimeout.

info: Evolve[0]
      Executing Migrate...
info: Evolve[0]
      Evolve initialized.
info: Evolve[0]
      Metadata validated.
info: Evolve[0]
      Error trying to release Evolve lock.
crit: Evolve[0]
      Database migration failed.
Application startup exception: System.InvalidOperationException: Connection must be valid and open to rollback transaction
   at MySql.Data.MySqlClient.MySqlTransaction.Rollback()
   at Evolve.Connection.WrappedConnection.Rollback()
   at Evolve.WrappedConnectionEx.TryRollback(WrappedConnection wrappedConnection)
   at Evolve.Evolve.ExecuteMigration(MigrationScript migration, DatabaseHelper db)
   at Evolve.Evolve.ExecuteAllMigration(DatabaseHelper db)
   at Evolve.Evolve.<InternalMigrate>g__Migrate|135_0(<>c__DisplayClass135_0& )
   at Evolve.Evolve.InternalMigrate(DatabaseHelper db)
   at Evolve.Evolve.<Migrate>b__134_0(DatabaseHelper db)
   at Evolve.Evolve.InternalExecuteCommand(Action`1 commandAction)
   at Evolve.Evolve.Migrate()
conn.ConnectionString = "server=" + host + ";uid=" + user + ";password=" + pass + ";database=" + database + ";";
                var evolve = new Evolve.Evolve(conn, msg => _logger.LogInformation(msg))
                {
                    Locations = new[] { "sql/" },
                    IsEraseDisabled = true,
                    CommandTimeout = 60,
                };

                evolve.Migrate();

Migration

ALTER TABLE `table` ADD COLUMN `column` INT NOT NULL;

CanIGetaPR avatar Nov 20 '21 03:11 CanIGetaPR

It's possible it was timing out, what's the default connection timeout ? documentation provides no value. I set to 600 this time and my next migration took 55 seconds so perhaps it's timeout indeed. Im sure the logging could be improved to state timeout was breached.

I had to manually approve this migration and skip it to get to my next migration so I couldnt test a higher value for timeout.

CanIGetaPR avatar Nov 20 '21 03:11 CanIGetaPR