Missing Tracking Data problem followup from previous post

A while ago I posted an article about an issue when the tracking information for BizTalk appeared not to be working and it was because the stream status was out of sync and information was not passing from the messagebox database to the tracking database.

https://geekswithblogs.net/michaelstephenson/archive/2008/10/30/126375.aspx

Since then I did a small SQL script which could be used to check if they were in sync and if not could fix the issue.  This script is below incase anyone needs it.

Note:

  • I havent tested it on BizTalk 2009 just on 2006 and 2006 R2
  • It isnt a good idea to use this in a production environment you might want to engage with Microsoft support first

/* This query will validate the stream status and check if its in sync.  If it isnt in sync then setting @IncludeUpdate to 1 will get the script to sync back up */

Declare @IncludeUpdate bit Set @IncludeUpdate = 0 -- Set me to 1 to update the values

Declare  @TrackingValue0 bigint,  @TrackingValue1 bigint,  @TrackingValue2 bigint,  @TrackingValue3 bigint,  @StatusValue0 bigint,  @StatusValue1 bigint,  @StatusValue2 bigint,  @StatusValue3 bigint

Select @TrackingValue0 = Min(SeqNum) From BizTalkMsgBoxDb.dbo.TrackingData_1_0 Select @TrackingValue1 = Min(SeqNum) From BizTalkMsgBoxDb.dbo.TrackingData_1_1 Select @TrackingValue2 = Min(SeqNum) From BizTalkMsgBoxDb.dbo.TrackingData_1_2 Select @TrackingValue3 = Min(SeqNum) From BizTalkMsgBoxDb.dbo.TrackingData_1_3

Select @StatusValue0 = LastSeqNum From BizTalkDtaDb.dbo.TDDS_StreamStatus Where Destinationid = 1 And Partitionid = 0

Select @StatusValue1 = LastSeqNum From BizTalkDtaDb.dbo.TDDS_StreamStatus Where Destinationid = 1 And Partitionid = 1

Select @StatusValue2 = LastSeqNum From BizTalkDtaDb.dbo.TDDS_StreamStatus Where Destinationid = 1 And Partitionid = 2

Select @StatusValue3 = LastSeqNum From BizTalkDtaDb.dbo.TDDS_StreamStatus Where Destinationid = 1 And Partitionid = 3

IF(@TrackingValue0!= @StatusValue0) Begin  Print 'The Stream Status for Partition 0 and Destination 1 is ' +  Cast(@StatusValue0 as varchar) + ' when it should be ' + Cast(@TrackingValue0 as varchar) End IF(@TrackingValue1!= @StatusValue1) Begin  Print 'The Stream Status for Partition 1 and Destination 1 is ' +  Cast(@StatusValue1 as varchar) + ' when it should be ' + Cast(@TrackingValue1 as varchar) End IF(@TrackingValue2!= @StatusValue2) Begin  Print 'The Stream Status for Partition 2 and Destination 1 is ' +  Cast(@StatusValue2 as varchar) + ' when it should be ' + Cast(@TrackingValue2 as varchar) End IF(@TrackingValue3!= @StatusValue3) Begin  Print 'The Stream Status for Partition 3 and Destination 1 is ' +  Cast(@StatusValue3 as varchar) + ' when it should be ' + Cast(@TrackingValue3 as varchar) End

If(@IncludeUpdate = 1) Begin  Print 'The stream status is being synced'  Update BizTalkDtaDb.dbo.TDDS_StreamStatus Set LastSeqNum = @TrackingValue0 - 1 Where Destinationid = 1 And Partitionid = 0  Update BizTalkDtaDb.dbo.TDDS_StreamStatus Set LastSeqNum = @TrackingValue1 - 1 Where Destinationid = 1 And Partitionid = 1  Update BizTalkDtaDb.dbo.TDDS_StreamStatus Set LastSeqNum = @TrackingValue2 - 1 Where Destinationid = 1 And Partitionid = 2  Update BizTalkDtaDb.dbo.TDDS_StreamStatus Set LastSeqNum = @TrackingValue3 - 1 Where Destinationid = 1 And Partitionid = 3  Print 'Stream status sync complete' End

This article is part of the GWB Archives. Original Author: Michael Stephenson

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.