HangfireIO / HangfireIO/Hangfire

Hangfire console raising MSDTC

Open
#1,696 0 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

I see old issues about MSDTC have been closed. But somehow, it still occurs in my development PC. I used v1.7.9 and just updated to 1.7.11 but still no luck. I also use [Hangfire.Console](https://github.com/pieceofsummer/Hangfire.Console). It fails when writing message to hangfire dashboard. Below is the stacktrace:

```
MSDTC on server 'COMPUTER' is unavailable.

System.Data.SqlClient.SqlException (0x80131904): MSDTC on server 'COMPUTER' is unavailable.
at System.Data.SqlClient.SqlConnection.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.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer, TransactionManagerRequestType request, String transactionName, TransactionManagerIsolationLevel isoLevel, Int32 timeout, SqlInternalTransaction transaction, TdsParserStateObject stateObj, Boolean isDelegateControlRequest)
at System.Data.SqlClient.TdsParser.GetDTCAddress(Int32 timeout, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.GetDTCAddress()
at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)
at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
at System.Data.SqlClient.SqlInternalConnection.EnlistTransaction(Transaction transaction)
at System.Data.SqlClient.SqlConnection.EnlistTransaction(Transaction transaction)
at Hangfire.SqlServer.SqlServerStorage.<>c__DisplayClass35_0`1.b__0(DbConnection connection)
at Hangfire.SqlServer.SqlServerStorage.UseConnection[T](DbConnection dedicatedConnection, Func`2 func)
at Hangfire.SqlServer.SqlServerStorage.UseTransaction[T](DbConnection dedicatedConnection, Func`3 func, Nullable`1 isolationLevel)
at Hangfire.SqlServer.SqlServerStorage.UseTransaction(DbConnection dedicatedConnection, Action`2 action)
at Hangfire.SqlServer.SqlServerWriteOnlyTransaction.Commit()
at Hangfire.Console.Storage.ConsoleStorage.AddLine(ConsoleId consoleId, ConsoleLine line)
at Hangfire.Console.Server.ConsoleContext.AddLine(ConsoleLine line)
at PakPos.Job.EmailImportJob.OnProcessedAction(PerformContext context, DateTime startExecutionTime, Int64 batchNumber, ReceivingAccount account, EmailImportError error, List`1 results) in C:\Sources\PakPos\PakPos.WebApi\Job\EmailImportJob.cs:line 208
at PakPos.WebApi.Job.EmailImportJob.<>c__DisplayClass12_0.b__1(ReceivingAccount account, EmailImportError error, List`1 results) in C:\Sources\PakPos\PakPos.WebApi\Job\EmailImportJob.cs:line 67
at PakPos.Domain.EmailImport.EmailImport.<>c__DisplayClass18_1.<b__3>d.MoveNext() in C:\Sources\PakPos\PakPos.Domain\EmailImport\EmailImport.cs:line 161
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at PakPos.Domain.EmailImport.EmailImport.d__18.MoveNext() in C:\Sources\PakPos\PakPos.Domain\EmailImport\EmailImport.cs:line 204
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at PakPos.WebApi.Job.EmailImportJob.d__12.MoveNext() in C:\Sources\PakPos\PakPos.WebApi\Job\EmailImportJob.cs:line 59
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
```

Any idea for the solution?

Contributor guide

Open the contributing guide

Research direction

Start with Hangfire.SqlServer.SqlServerStorage.UseTransaction and Hangfire.Console.Storage.ConsoleStorage.AddLine, the entry points shown in the stack trace. Reproduce a dashboard message write using the reported versions and inspect where the SQL transaction enlists in MSDTC; done means identifying a project-level cause and a verified resolution.

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
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.