title: BizTalk SQL Server Job always fails after some hours
body: <p>We have BizTalk 2016 running on SQL Server 2016 AlwaysOn.</p>
  
  <p>The SQL Server Agent Job <code>MessageBox_Message_ManageRefCountLog_BizTalkMsgBoxDb</code> is doing its thing but after some hours it fails. Sometimes 10 hours sometimes 90 hours or anything in between. I know, the job is designed to run forever and in a case of an error restarts itself within a minute. But I would like to know the actual error message for this failed job. The job history is not helpful because the job log entry is truncated.</p>
  
  <p><a href="https://i.stack.imgur.com/N07NR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N07NR.png" alt="Job History"></a></p>
  
  <p>A failover is not happening. The question is: WHY is this job failing and ultimately: how do I stop it from doing that?</p>
  
  <hr>
  
  <p>I have set-up the extended monitoring of the failing step and it revealed, that the job failed because of a deadlock and it was chosen as the deadlock victim. So now is the question, why is there a deadlock? Is <code>MessageBox_Message_ManageRefCountLog_BizTalkMsgBoxDb</code>known for deadlock issues?</p>
  
  <p><a href="https://i.stack.imgur.com/ezuAs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ezuAs.png" alt="Setup Sql Server Job for more history logging"></a></p>