Skip to content

Commit

Permalink
Make transaction scope timeout the same as command timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sebgod committed Feb 10, 2025
1 parent f4b5d51 commit 6798110
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/grate.core/Migration/GrateMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ public async Task Migrate()
// Start the transaction, if configured
if (runInTransaction)
{
scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
// use command timeout as the max timeout and transaction scope timeout, if greater than current MaxTimeout
var transactionTimeout = config.CommandTimeout > 0
? new [] {TransactionManager.MaxTimeout, TimeSpan.FromSeconds(config.CommandTimeout) }.Max();
: TransactionManager.MaxTimeout;

TransactionManager.MaxTimeout = transactionTimeout;
scope = new TransactionScope(TransactionScopeOption.Required, transactionTimeout, TransactionScopeAsyncFlowOption.Enabled);
}

bool exceptionOccured = false;
Expand Down

0 comments on commit 6798110

Please sign in to comment.