When you configure a transactional replication that uses the -SkipErrors parameter in Microsoft SQL Server 2005, the Distribution Agent may skip some rows. This behavior causes a data inconsistency issue between the publisher and the subscribers.
Additionally, when this problem occurs, the Distribution Agent may display the following messages:
007-05-18 22:49:38.195 The process failed to complete last batch in multi-streaming mode, it has been reset to single connection mode and is retrying the operation.
007-05-18 22:49:38.273 Skipped 1 error(s) when applying transactions at the Subscriber. 007-05-18 22:49:38.367 101 transaction(s) with 100 command(s) were delivered.
007-05-18 22:49:38.477 100 transaction(s) with 100 command(s) were delivered. 007-05-18 22:49:38.570 Skipped 1 error(s) when applying transactions at the Subscriber.
007-05-18 22:49:38.664 100 transaction(s) with 100 command(s) were delivered.
The fix for this issue was first released in Cumulative Update 2. For more information about how to obtain this cumulative update package for SQL Server 2005 Service Pack 2, click the following article number to view the article in the Microsoft Knowledge Base:
936305 Cumulative update package 2 for SQL Server 2005 Service Pack 2
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 fix release. Microsoft recommends that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
937137 The SQL Server 2005 builds that were released after SQL Server 2005 Service Pack 2 was released
Microsoft SQL Server 2005 hotfixes are created for specific SQL Server service packs. You must apply a SQL Server 2005 Service Pack 2 hotfix to an installation of SQL Server 2005 Service Pack 2. By default, any hotfix that is provided in a SQL Server service pack is included in the next SQL Server service pack.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
By default, when the Distribution Agent encounters an error, the Distribution Agent should be stopped. If you use the –SkipErrors parameter for specific errors, the Distribution Agent skips those errors and continues to process successive transactions.
Steps to reproduce the problem
Set up a replication environment. To do this, run the following scripts in SQL Query Analyzer.
use mastergoexec sp_adddistributor @distributor = @@SERVERNAMEgoexec sp_adddistributiondb @database = 'distribution'goexec sp_adddistpublisher @publisher = @@SERVERNAME, @distribution_db = 'distribution'goexec sp_replicationdboption pubdb, publish, falsegoexec sp_replicationdboption subdb, publish, falsegoif db_id('pubdb') is not null drop database pubdbgocreate database pubdbgoif db_id('subdb') is not null drop database subdb gocreate database subdbgoexec sp_replicationdboption pubdb, publish, truegouse pubdbgocreate table t(c1 int primary key, c2 int, c3 sysname null, c4 nchar(200) default 'a')gocreate unique index c2_idx on t(c2)gosp_addpublication @publication = 'p1', @status = 'active'gosp_addarticle @publication = 'p1', @article = 'a1', @source_table = 't', @schema_option = 0x00000000000300f3gosp_addsubscription @publication = 'p1', @article = 'all', @subscriber = @@servername, @destination_db = 'subdb'go
Save the following command as a batch file, and then run the file to insert data.
Microsoft SQL Server 2005 Developer Edition, Microsoft SQL Server 2005 Enterprise Edition, Microsoft SQL Server 2005 Standard Edition, Microsoft SQL Server 2005 Standard X64 Edition, Microsoft SQL Server 2005 Enterprise X64 Edition, Microsoft SQL Server 2005 Standard Edition for Itanium-based Systems, Microsoft SQL Server 2005 Enterprise Edition for Itanium-based Systems