question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Distributed transactions failures when running EF Core tests on main

See original GitHub issue

✘ Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorCreateTablesTest.Creates_schema_in_existing_database_test(async: True, ambientTransaction: True)

Distributed transaction started\r\nExpected: False\r\nActual:   True
   at Microsoft.EntityFrameworkCore.TestUtilities.TestStore.DistributedTransactionListener.DistributedTransactionStarted(Object sender, TransactionEventArgs e) in C:\github\efcore\test\EFCore.Specification.Tests\TestUtilities\TestStore.cs:line 129
   at System.Transactions.TransactionManager.ProcessExistingTransactions(TransactionStartedEventHandler eventHandler)
   at System.Transactions.TransactionManager.add_DistributedTransactionStarted(TransactionStartedEventHandler value)
   at Microsoft.EntityFrameworkCore.TestUtilities.TestStore.DistributedTransactionListener..ctor() in C:\github\efcore\test\EFCore.Specification.Tests\TestUtilities\TestStore.cs:line 125
   at Microsoft.EntityFrameworkCore.TestUtilities.TestStore.CreateTransactionScope(Boolean useTransaction) in C:\github\efcore\test\EFCore.Specification.Tests\TestUtilities\TestStore.cs:line 108
   at Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorTest.CreateTransactionScope(Boolean useTransaction) in C:\github\efcore\test\EFCore.SqlServer.FunctionalTests\SqlServerDatabaseCreatorTest.cs:line 666
   at Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorCreateTablesTest.Creates_schema_in_existing_database_test(Boolean async, Boolean ambientTransaction) in C:\github\efcore\test\EFCore.SqlServer.FunctionalTests\SqlServerDatabaseCreatorTest.cs:line 484

✘ Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorEnsureCreatedTest.Creates_schema_in_existing_database(async: True, ambientTransaction: True)

Distributed transaction started\r\nExpected: False\r\nActual:   True
   at Microsoft.EntityFrameworkCore.TestUtilities.TestStore.DistributedTransactionListener.DistributedTransactionStarted(Object sender, TransactionEventArgs e) in C:\github\efcore\test\EFCore.Specification.Tests\TestUtilities\TestStore.cs:line 129
   at System.Transactions.TransactionManager.ProcessExistingTransactions(TransactionStartedEventHandler eventHandler)
   at System.Transactions.TransactionManager.add_DistributedTransactionStarted(TransactionStartedEventHandler value)
   at Microsoft.EntityFrameworkCore.TestUtilities.TestStore.DistributedTransactionListener..ctor() in C:\github\efcore\test\EFCore.Specification.Tests\TestUtilities\TestStore.cs:line 125
   at Microsoft.EntityFrameworkCore.TestUtilities.TestStore.CreateTransactionScope(Boolean useTransaction) in C:\github\efcore\test\EFCore.Specification.Tests\TestUtilities\TestStore.cs:line 108
   at Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorTest.CreateTransactionScope(Boolean useTransaction) in C:\github\efcore\test\EFCore.SqlServer.FunctionalTests\SqlServerDatabaseCreatorTest.cs:line 666
   at Microsoft.EntityFrameworkCore.SqlServerDatabaseCreatorEnsureCreatedTest.Creates_physical_database_and_schema_test(ValueTuple`4 options) in C:\github\efcore\test\EFCore.SqlServer.FunctionalTests\SqlServerDatabaseCreatorTest.cs:line 263

✘ Microsoft.EntityFrameworkCore.Update.MismatchedKeyTypesSqlServerTest.Can_update_and_delete_with_string_FK_and_GUID_PK

System.InvalidOperationException : The operation is not valid for the current state of the enlistment.
   at System.Transactions.EnlistmentState.Aborted(InternalEnlistment enlistment, Exception e)
   at System.Transactions.SinglePhaseEnlistment.Aborted()
   at Microsoft.Data.SqlClient.SqlDelegatedTransaction.Rollback(SinglePhaseEnlistment enlistment)
   at System.Transactions.TransactionStateDelegatedAborting.EnterState(InternalTransaction tx)
   at System.Transactions.Transaction.Rollback()
   at System.Transactions.TransactionScope.InternalDispose()
   at System.Transactions.TransactionScope.Dispose()
   at Microsoft.EntityFrameworkCore.Update.MismatchedKeyTypesSqlServerTest.Can_update_and_delete_with_string_FK_and_GUID_PK() in C:\github\efcore\test\EFCore.SqlServer.FunctionalTests\Update\MismatchedKeyTypesSqlServerTest.cs:line 236
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Oct 7, 2022

Yeah, this is the same as before.

I need to prepare that branch/PR which would allow us to catch this when it’s promoted.

1reaction
ajcvickerscommented, Sep 16, 2022

FYI, I have run many local builds over the last few days and have not seen this again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Transactions - EF Core
If any of the changes fail, then the transaction is rolled back and none of the changes are applied to the database.
Read more >
This platform does not support distributed transactions.
.NET Core doesn't support Distributed Transactions because it would require a different transaction manager on each platform.
Read more >
TransactionAbortedException when performing queries in ...
Below code reproduces the error. It runs 100K times 2 queries in parallel where each 2 queries are inside a single transaction scope....
Read more >
Understanding Transactions in Entity Framework Core
This article covers the fundamentals of transactions in Entity Framework Core, how to work with them, different strategies to implement, ...
Read more >
Working With Transactions in Entity Framework Core and ...
This article presents a discussion on how we can work with transactions using Entity Framework Core and Entity Developer for data access.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found