Open Usergitbit opened 2 years ago
This is happening to me, It seems that the problem is that the default timeout for the ambient transaction is 60 seconds. So long duration migrations with RollbackAll or CommitAll will fail.
The solution should be easy, add a new property "AmbientTransactionTimeout" in the Evolve class and pass it to the TransactionScope constructor.
Could you take a look at it? This is a feature we would love to see working properly.
I created a PR https://github.com/lecaillon/Evolve/pull/293
I created a PR #293
This will only fix the issue if the timeout is under 10m (the max transaction default timeout). If you need it higher than that then the reflection hack is needed. If this were to be done in the library I think the max timeout could be modified before the migrations run then set back to the initial value.
I created a PR #293
This will only fix the issue if the timeout is under 10m (the max transaction default timeout). If you need it higher than that then the reflection hack is needed. If this were to be done in the library I think the max timeout could be modified before the migrations run then set back to the initial value.
I just pushed a commit with the change. Check out if you can.
I created a PR #293
This will only fix the issue if the timeout is under 10m (the max transaction default timeout). If you need it higher than that then the reflection hack is needed. If this were to be done in the library I think the max timeout could be modified before the migrations run then set back to the initial value.
I just pushed a commit with the change. Check out if you can.
Im the one that created the PR, just changed to my main account.
When this will be released?
@danigt91 Already done: https://github.com/lecaillon/Evolve/pull/293#issuecomment-1407044551
Long running migrations (10m+) with Evolve 3.0 on Postgres in Azure (v11) with Npgsql 6.0.6 (.NET 6) throw the following exception:
The connection parameters for timeouts we use are
CommandTimeout=900;InternalCommandTimeout=-1;
. It works fine if usingTransactionKind.CommitEach
. It always seems to happen after about 60000-70000 ms. I've tried debugging the issue and it seems the cause is this part:The ambient transaction has its own timeout of 60000ms which matches with the time after which the exception is thrown. I tried changing that block to:
and this seems to solve the problem but it breaks the
TransactionKind.RollbackAll
mode. But the idea would be to handle the transaction at the connection level since then it would respect the connection string parameters.Modifying the timeouts for the ambient transaction might be possible as well but it seems to be tricky (see https://github.com/dotnet/runtime/issues/1418#issuecomment-786027181) and it did not work for me when I tried it (perhaps I didn't call the methods at the appropiate time). I'm also not sure if it would work with timeouts set in the connection string parameters, I think it would need the
CommandTimeout
parameter to be set explicitly in Evolve.EDIT: the
TransactionKind.CommitAll
works with the reflection hack if both max and default are set (along with the cached and validated members).