我收到一个
使用EF Core 2.1时出现System.Data.SqlClient.SqlException(0x80131904):Microsoft分布式事务处理协调器(MS DTC)已取消了分布式事务处理。
错误。完整的堆栈跟踪位于此消息的底部。
这是基本过程:
MSDTC错误在步骤3间歇性但频繁发生。步骤2和3中的原始表和生产表位于同一SQL Server上的单独数据库中。作为第5步的一部分,还有一个对单独的SQL Server的调用,但我得到的唯一错误是在第3步期间取消了MSDTC。
我知道.NET Core不支持MSDTC,但是我不确定为什么将此过程的这一部分提升为MSDTC。我没有任何显式事务,并且通过appsettings中的ConnectionStrings为每个数据库标准化了连接字符串。
任何见识表示赞赏。
authAPI.usp_AuthTransform @CorrelationID, @AuthStateID OUT, @CorrelationSeqID OUT
System.Data.SqlClient.SqlException (0x80131904): The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader()
at System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult)
at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
ClientConnectionId:24a868f2-3f00-4e07-92fd-7537beb23d33
Error Number:1206,State:118,Class:18
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Private.CoreLib.dll
Exception thrown: 'System.Data.SqlClient.SqlException' in System.Private.CoreLib.dll
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.15\System.IO.MemoryMappedFiles.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
nH.AuthRequestIntake.nHDischarge.ReceiveHandler:Error: 353c5648-5ef0-44b9-bd5b-ac1395243ac6-System.Data.SqlClient.SqlException (0x80131904): The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader()
at System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult)
at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlCommandAsync(DatabaseFacade databaseFacade, RawSqlString sql, IEnumerable`1 parameters, CancellationToken cancellationToken)
at nH.AuthRequestIntake.Domain.AuthRequestReceivedEventHandler`2.TransformToAuthRequestAsync(AuthRequest rawRequest, IIncomingDbContext dbContext) in C:\Users\scott.carter\source\repos\authrequestintake\nH.AuthRequestIntake.Domain\AuthRequestReceivedEventHandler.cs:line 170
at nH.AuthRequestIntake.Domain.AuthRequestReceivedEventHandler`2.HandleAsync(IDomainEvent domainEvent) in C:\Users\scott.carter\source\repos\authrequestintake\nH.AuthRequestIntake.Domain\AuthRequestReceivedEventHandler.cs:line 68
ClientConnectionId:24a868f2-3f00-4e07-92fd-7537beb23d33
Error Number:1206,State:118,Class:18
System.Data.SqlClient.SqlException (0x80131904): The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.CompleteAsyncExecuteReader()
at System.Data.SqlClient.SqlCommand.EndExecuteNonQueryInternal(IAsyncResult asyncResult)
at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlCommandAsync(DatabaseFacade databaseFacade, RawSqlString sql, IEnumerable`1 parameters, CancellationToken cancellationToken)
at nH.AuthRequestIntake.Domain.AuthRequestReceivedEventHandler`2.TransformToAuthRequestAsync(AuthRequest rawRequest, IIncomingDbContext dbContext) in C:\Users\scott.carter\source\repos\authrequestintake\nH.AuthRequestIntake.Domain\AuthRequestReceivedEventHandler.cs:line 170
at nH.AuthRequestIntake.Domain.AuthRequestReceivedEventHandler`2.HandleAsync(IDomainEvent domainEvent) in C:\Users\scott.carter\source\repos\authrequestintake\nH.AuthRequestIntake.Domain\AuthRequestReceivedEventHandler.cs:line 68
ClientConnectionId:24a868f2-3f00-4e07-92fd-7537beb23d33
Error Number:1206,State:118,Class:18```
答案 0 :(得分:0)
事实证明这是一条红鲱鱼。我读过某个地方的MSDTC问题有时掩盖了其他问题,建议进行数据库跟踪。可以肯定的是,跟踪显示在负载下临时表正在通过连接删除,因此我们现在正在努力解决此问题。
感谢所有阅读并考虑了该问题的人!