HangfireIO / HangfireIO/Hangfire

Transaction not disposed upon Hangfire.States.StateChangeProcess.ApplyState

Open
#252 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.1k
Forks
1.8k
Avg merge
1h 19m
Merged PRs (30d)
1

Description

Using Hangfire Sql server storage, I get these failures from time to time:

```
The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.

System.InvalidOperationException: The transaction associated with the current connection has completed but has not been disposed. The transaction must be disposed before the connection can be used to execute SQL statements.
at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc, Boolean sync, TaskCompletionSource`1 completion, Int32 startRpc, Int32 startParam)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action`2 paramReader) in d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 3310
at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1310
at Dapper.SqlMapper.Execute(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Nullable`1 commandTimeout, Nullable`1 commandType) in d:\Dev\dapper-dot-net\Dapper NET40\SqlMapper.cs:line 1185
at Hangfire.SqlServer.SqlServerWriteOnlyTransaction.<>c__DisplayClass8.b__7(SqlConnection x)
at Hangfire.SqlServer.SqlServerWriteOnlyTransaction.Commit()
at Hangfire.States.StateChangeProcess.ApplyState(ApplyStateContext context, IEnumerable`1 filters)
at Hangfire.States.StateChangeProcess.ChangeState(StateContext context, IState toState, String oldStateName)
```

My code uses the same database, but on a different connection (and other tables), so I do not think my code interferes with Hangfire.

Anything I can do to determine the cause of this issue?

Contributor guide

Open the contributing guide

Research direction

Begin at Hangfire.SqlServer.SqlServerWriteOnlyTransaction.Commit in the stack trace, then trace the call from Hangfire.States.StateChangeProcess.ApplyState. Reproduce or isolate the transaction lifecycle around the failing SQL operation; done means identifying the cause of the undisposed completed transaction and documenting a reliable fix or diagnostic result.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.