lecaillon / Evolve

Database migration tool for .NET and .NET Core projects. Inspired by Flyway.
https://evolve-db.netlify.com
MIT License
849 stars 111 forks source link

Is the timeout capped at 60 seconds somewhere? #314

Closed sjd2021 closed 11 months ago

sjd2021 commented 11 months ago

When running the migrations via C#, I specify the options like this:

 Evolve evolve = new Evolve(connection, (Action<string>) (msg => logger.LogInformation("Evolve log: {Message}", (object) msg)))
      {
        Locations = list,
        IsEraseDisabled = true,
        CommandTimeout = 300,
        TransactionMode = TransactionKind.CommitAll
      };

But I've noticed that the timeout seems to stop at exactly 60 seconds at which point I'll get this notification:

EvolveDb.EvolveSqlException: 25P02: current transaction is aborted, commands ignored until end of transaction block Sql query: SELECT pg_advisory_unlock(12345) 25P02: current transaction is aborted, commands ignored until end of transaction block\n ---> Npgsql.PostgresException (0x80004005): 25P02: current transaction is aborted, commands ignored until end of transaction block

I occasionally up the timeout for a long-running command from 30 seconds to 5 minutes, but it seems to stop at 60 seconds no matter what.

sjd2021 commented 11 months ago

I'm stepping into the Evolve ExecuteMigration method, and this stopwatch ends at 1 minute each time depending on how fast I let the breakpoints slip through:

image

sjd2021 commented 11 months ago

I confirmed that the exact same connection string and timeouts I pass into the Evolve constructor can execute this same SQL statement or any SQL statement lasting more than 1 minute. Evolve must be using some sort of weird overarching settings..

edit: I found the other timeout setting, AmbientTransactionTimeout which I hadn't seen before for some reason. It isn't included in the Options page.

lecaillon commented 11 months ago

Yes sorry, not documented yet. I'll do it when I'll upgrade some part of Evolve to .NET 8

Indeed when TransactionMode = TransactionKind.CommitAll Evolve will use .NET TransactionScope and all its default settings unless you define AmbientTransactionTimeout

Don't hesitate to tell me if it works now with a 10 min timeout for example

Thanks

sjd2021 commented 11 months ago

@lecaillon Yes, it is working perfectly now. My week is looking pretty good now that I won't have to perform any manual migrations or changelog manipulations 😅

I read up on the changes required to update transaction defaults for versions prior to .NET 7 (which has an API for it) and saw you had already implemented it clearly in #295 .

lecaillon commented 11 months ago

Great thanks for your feedbacks, see you :)