提交数据库事务时报告错误,但无法确定事务是成功还是失败

时间:2018-06-12 11:00:31

标签: entity-framework-4

我们正在使用Entity框架来执行CRUD操作。我们观察到非常罕见的情况,对于来自API的第一个请求,我们得到如下错误..但是在每个其他请求之后它工作正常。请帮帮我

{"Message":"An error has occurred.","ExceptionMessage":"An error was reported while committing a database transaction but it could not be determined whether the transaction succeeded or failed on the database server. See the inner exception and http://go.microsoft.com/fwlink/?LinkId=313468 for more information.","ExceptionType":"System.Data.Entity.Infrastructure.CommitFailedException","StackTrace":" at System.Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch [TTarget,TInterceptionContext](TTarget目标,Action 2 operation, TInterceptionContext interceptionContext, Action 3执行,Action 3 executed)\r\n at System.Data.Entity.Infrastructure.Interception.DbTransactionDispatcher.Commit(DbTransaction transaction, DbInterceptionContext interceptionContext)\r\n at System.Data.Entity.Core.EntityClient.EntityTransaction.Commit()\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func 1 func,IDbExecutionStrategy executionStrategy,Boolean startLocalTransaction,Boolean releaseConnectionOnSuccess)\ r \ n在System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions选项,IDbExecutionStrategy executionStrategy,Boolean startLocalTransaction)\ r \ n在System.Data.Entity.Core.Objects.ObjectContext。&lt;&gt; c__DisplayClass2a.b__27( )\ r \ n在System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute [TResult](Func 1 operation)\r\n at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)\r\n at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)\r\n at System.Data.Entity.Internal.InternalContext.SaveChanges()\r\n at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()\r\n at System.Data.Entity.DbContext.SaveChanges()\r\n at SeritiApp.Data.UnitOfWork.MasterUnitOfWork.Save() in E:\\DevelopmentSpace\Web App\\App\\App.Data\\UnitOfWork\\MasterUnitOfWork.cs:line 158\r\n at SeritiAppMVC.Services.SeritiMasterServices.CreateAPIErrorLogEnrty(ApiLogEntryEntity apiLogEntryEntity)\r\n at SeritiAppMVC.WebAPI.Utils.ApiLogHandler.<>c__DisplayClass5_1.<SendAsync>b__1(Task 1任务)\ r \ n在System.Threading.Tasks.ContinuationResultTaskFromResultTask 2.InnerInvoke()\r\n at System.Threading.Tasks.Task.Execute()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at SeritiAppMVC.WebAPI.Utils.ApiLogHandler.<SendAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Owin.PassiveAuthenticationMessageHandler.<SendAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.HttpServer.<SendAsync>d__0.MoveNext()","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.","ExceptionType":"System.Data.SqlClient.SqlException","StackTrace":" at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) \ r \ n在System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj,布尔callerHasConnectionLock,布尔asyncClose个)\ r \ n在System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj,UInt32的误差)\ r \ n在System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync(个)\ r \ n System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()\ r \ n at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()\ r \ n在System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte&amp;值)\ r \ n在System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean&amp; dataReady)\ r \ n在System.Data.SqlClient.TdsParser.Run (runBehavior runBehavior,SqlCommand的cmdHandler,SqlDataReader的数据流,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj个)\ r \ n在System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(字节[]缓冲液,TransactionManagerRequestType请求,字符串transactionName,TransactionManagerIsolationLevel ISOLEVEL,的Int32超时,SqlInternalTransaction交易,TdsParserStateObject stateObj,Boolean isDelegateControlRequest)\ r \ n在System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest,String transactionName,IsolationLevel iso,SqlInternalTransaction internalTransaction,Boolean isDelegateControlRequest)\ r \ n在System.Data.SqlClien t.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest,String name,IsolationLevel iso,SqlInternalTransaction internalTransaction,Boolean isDelegateControlRequest)\ r \ n在System.Data.SqlClient.SqlInternalTransaction.Commit()\ r \ n,位于System.Data.SqlClient.SqlTransaction。在系统的System.Data.Entity.Infrastructure.Interception.DbTransactionDispatcher.b__c(DbTransaction t,DbTransactionInterceptionContext c)\ r \ n的Glimpse.Ado.AlternateType.GlimpseDbTransaction.Commit()\ r \ n中提交()\ r \ n .Data.Entity.Infrastructure.Interception.InternalDispatcher 1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action 2操作,TInterceptionContext interceptionContext,Action 3 executing, Action 3执行)“,”InnerException“:{”消息“:”发生了错误。“,” ExceptionMessage“:”等待操作超时“,”ExceptionType“:”System.ComponentModel.Win32Exception“,”StackTrace“:null}}}

`

0 个答案:

没有答案