5

NServiceBus.Host.exeホスト プロセスを使用して、NServiceBus ベースのサービスを実行しています。

過去数か月間に 2 回、Windows サービスが突然停止し、アプリケーション イベント ログに次のイベントが記録されました。

アプリケーション: NServiceBus.Host.exe フレームワーク バージョン: v4.0.30319 説明: 未処理の例外のため、プロセスが終了しました。例外情報: System.InvalidOperationException スタック: System.Transactions.TransactionState.ChangeStatePromotedPhase0(System.Transactions.InternalTransaction) で System.Transactions.Phase0VolatileDemultiplexer.InternalPrepare() で System.Transactions.VolatileDemultiplexer.PoolablePrepare(System.Object) で System.Transactions .Oletx.OletxVolatileEnlistment.Prepare(System.Transactions.Oletx.Oletx.OletxVolatileEnlistmentContainer) で System.Transactions.Oletx.OletxPhase0VolatileEnlistmentContainer.Phase0Request(Boolean) で System.Transactions.Oletx.OletxTransactionManager.ShimNotificationCallback(System.Object, Boolean) で System.Threading。 _ThreadPoolWaitOrTimerCallback.

このエラーは、ネットワークが不安定な状態が数分間続いたときに発生しました (たとえば、log4net ログ ファイルに表示されるデータベースに対する多数のタイムアウト)。

ここで何が失敗しているのかについてのアイデアはありますか?

log4net ログファイルに致命的なエラーはありません。

バージョン:

  • Windows Server 2008 R2
  • .NET フレームワーク 4.5.2
  • NServiceBus 4.7.5
  • NHibernate 3.3.3.4001 (サガ、サブスクリプション、およびタイムアウトの永続化に使用)
  • SQL Server 2012
4

1 に答える 1

3

It seems the behavior you see is related to how NHibernate handles the TransactionCompleted event. This questions is also somehow related to this question.

The AdoNetWithDistributedTransactionFactory registers an anonymous delegate on the TransactionCompleted event. This event gets fired on a background thread by using ThreadPool.QueueUserWorkItem. If that operation throws an exception due to connectivity issues with your database server (i.ex. due to a network partition) this exception gets raised as an unobserved exception on the AppDomain. UnhandledExceptions tear down the AppDomain and therefore also the NServiceBus.Host.

The best possible workaround for that would be to register an UnhandledException handler on the current AppDomain like the following

AppDomain.CurrentDomain.UnhandledException += OnUnhandledException

private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
    LogManager.GetLogger(typeof(AppDomain)).Fatal(“Unhandled exception”, e.ExceptionObject as Exception);
}

More information see

When this fixed the intermediate problem it would make sense to find the root cause of the connection issues with your database server in combination with NHibernate

于 2015-11-02T14:44:53.180 に答える