signumsoftware / framework

Open Source framework for writing data-centric applications using the latest versions of .Net Core, C# (not-nullable), ASP.NET Web API, Typescript (strict), React, D3 and Sql Server or PostgreeSQL
https://www.signumsoftware.com/en/Framework
MIT License
222 stars 84 forks source link

Problems with transactions #594

Closed ce-kkoziel closed 1 year ago

ce-kkoziel commented 1 year ago

Dear @olmobrutall

I have problems with transactions which occurs from time to time. Only restart of a service helps me. Please take a look and give me a feedback/some hint how to handle this in my code.

I am just doing:

Database.Query<SomeEntity>().Count(Prediction);

Framework version from 18d765b6670020d13cea46110ba9ae8cec25e0c0 commit

1.The server failed to resume the transaction. Desc:3e00006b6d. The transaction active in this session has been committed or aborted by another session.

` at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)

at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)

at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)

at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

at Microsoft.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)

at Microsoft.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)

at Microsoft.Data.SqlClient.SqlInternalConnection.BeginSqlTransaction(IsolationLevel iso, String transactionName, Boolean shouldReconnect)

at Microsoft.Data.SqlClient.SqlConnection.BeginTransaction(IsolationLevel iso, String transactionName)

at Microsoft.Data.SqlClient.SqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)

at Signum.Engine.Transaction.RealTransaction.Start() in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\Transaction.cs:line 139

at Signum.Engine.Transaction.get_CurrentConnection() in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\Transaction.cs:line 516

at Signum.Engine.SqlServerConnector.NewCommand(SqlPreCommandSimple preCommand, SqlConnection overridenConnection, CommandType commandType) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\SqlServerConnector.cs:line 126

at Signum.Engine.SqlServerConnector.UnsafeExecuteDataReader(SqlPreCommandSimple preCommand, CommandType commandType) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\SqlServerConnector.cs:line 281

at Signum.Engine.Linq.TranslateResult`1.b__18_0() in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Linq\TranslateResult.cs:line 240

at Signum.Engine.Connection.SqlServerRetry.Retry[T](Func`1 action) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\SqlServerRetry.cs:line 50

at Signum.Engine.Linq.DbQueryProvider.Execute(Expression expression) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Linq\DbQueryProvider.cs:line 31

at Signum.Utilities.ExpressionTrees.QueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Utilities\ExpressionTrees\QueryProvider.cs:line 36 `

2. This SqlTransaction has completed; it is no longer usable.

` at Microsoft.Data.SqlClient.SqlTransaction.ZombieCheck()

at Microsoft.Data.SqlClient.SqlTransaction.Rollback()

at Signum.Engine.Transaction.RealTransaction.Rollback(Exception ex) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\Transaction.cs:line 182

at Signum.Engine.Transaction.Dispose() in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\Transaction.cs:line 592

at Signum.Engine.Linq.TranslateResult`1.b__18_0() in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Linq\TranslateResult.cs:line 270

at Signum.Engine.Connection.SqlServerRetry.Retry[T](Func`1 action) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Connection\SqlServerRetry.cs:line 50

at Signum.Engine.Linq.DbQueryProvider.Execute(Expression expression) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Engine\Linq\DbQueryProvider.cs:line 31

at Signum.Utilities.ExpressionTrees.QueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression) in C:\Solutions\CE.PL.EasyClaim.Live\Framework\Signum.Utilities\ExpressionTrees\QueryProvider.cs:line 36 `

olmobrutall commented 1 year ago

Sorry, I feel unable to give you any tip for this error. Looks like an SQL Server problem. Maybe updating to the latest framework helps, since it uses Microsoft.Data.SqlClient 5.1.0

ce-kkoziel commented 1 year ago

Ok. Thanks for response.