读书人

Error number: 20598 The row was not

发布时间: 2013-01-26 13:47:02 作者: rapoo

Error number: 20598 The row was not found at the Subscriber when applying the replicated command.

今天测试Replication遇到下面的错误:

The row was not found at the Subscriber when applying the replicatedcommand.(Source: MSSQLServer, Error number: 20598)

if @@trancount > 0 rollback tran
(Transaction sequence number: 0x0000004100000162000400000000, Command ID: 1)

这个错误说明了当发布服务器上执行的语句在订阅服务器上执行时无法在订阅服务器找到对应的数据,所以出错。在默认情况下,发布代理遇到错误时就会停止,所以后影响后面的发布执行。

解决这个问题的根本原因首先要查出那些数据不同步,可以使用DATADIFF工具验证两边数据,然后同步数据(或者重新初始化)。

查询是哪个Article出了问题可以使用下面的语句:


USE [distribution]

select * from dbo . MSarticles

where article_idIN(SELECT Article_idfrom MSrepl_commands

where xact_seqno= 0x0000004100000162000400000000)

结果如下(这个例子test表数据有问题):

Error number: 20598 The row was not found at the Subscriber when applying the replicated command

但是发现那些数据不同步可能会花比较长的时间,为了能够让发布尽快同步,我们可以跳过事务复制中的错误。对于事务复制,有两种方法可以跳过在分发过程中遇到的错误:

分发代理的-SkipErrors参数,可用来跳过某种类型的错误。有错误的事务将不提交,但后续的事务将提交。

sp_setsubscriptionxactseqno存储过程,可用来跳过一个或多个导致错误的事务。非SQL Server的订阅服务器没有此选项。

使用-SkipErrors参数,可以让代理将错误记录下来,而Agent继续运行。通常的做法是在DistributionAgent profile中使用“Continue On Data ConsistencyErrors”。如图:

Error number: 20598 The row was not found at the Subscriber when applying the replicated command

Error number: 20598 The row was not found at the Subscriber when applying the replicated command

注意:代理参数更改将在下次启动代理时生效。如果代理连续运行,您必须停止并重新启动代理。

更多详细信息参考:SkippingErrors in Transactional Replication:http://technet.microsoft.com/en-us/library/ms151331(v=sql.105).aspx

读书人网 >Ruby Rails

热点推荐