The process could not execute 'sp_repldone/sp_replcounters' on 'ServerName'

昨天发现发布服务器S(SQL Server 2008 R2),出现大量如下错误

clip_image001

错误细节如下所示:

Date 10/16/2013 4:04:14 PM

Log SQL Server (Current - 10/16/2013 3:44:00 PM)

Source spid52

Message

Replication-Replication Transaction-Log Reader Subsystem: agent xxxxx failed. The process could not execute 'sp_repldone/sp_replcounters' on ' ServerName'.

我在发布服务器S上启用Launch Replication Monitor(复制监视器),查看一些具体情况,如下所示

clip_image002

 

Error messages:

The process could not execute 'sp_repldone/sp_replcounters' on 'ServerName'. (Source: MSSQL_REPL, Error number: MSSQL_REPL20011)

Get help: http://help/MSSQL_REPL20011

The specified LSN {00000000:00000000:0000} for repldone log scan occurs before the current start of replication in the log {000988e1:0000577e:00b4}. (Source: MSSQLServer, Error number: 18768)

Get help: http://help/18768

The process could not set the last distributed transaction. (Source: MSSQL_REPL, Error number: MSSQL_REPL22017)

Get help: http://help/MSSQL_REPL22017

The process could not execute 'sp_repldone/sp_replcounters' on 'ServerName'. (Source: MSSQL_REPL, Error number: MSSQL_REPL22037)

Get help: http://help/MSSQL_REPL22037

另外发现Log  Reader Agent(日志读取器代理)呈现错误状态,首先尝试通过关闭Log Reader Agent(日志读取器代理),然后重启Log Reader Agent(日志读取器代理),Log Reader Agent(日志读取器代理)依然启动不了,重启SQL Server Agent(SQL Server 代理),问题仍然存在,检查msrepl_commands记录数,当时记录数是761490,可以排除颁发库的 msrepl_commands 表里面的数据太多,导致清理花费太长时间的原因。

SELECT COUNT(1) FROM msrepl_commands

于是执行下面SQL:

EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0,    @time = 0, @reset = 1

EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0,    @time = 0, @reset = 0

exec sp_replflush

 SQL执行完成后,日志读取器代理成功启动。重启初始化订阅后,问题解决。

下面是MSDN关于sp_repflush 和sp_repldone的解释:

 


 

sp_replflush 用于事务复制。

为了提高效率,项目定义存储在缓存中。只要修改或删除项目定义,其他复制存储过程都可使用 sp_replflush

只有一个客户端连接有权访问给定数据库的日志读取器。如果某个客户端有权访问数据库的日志读取器,则执行 sp_replflush 将导致该客户端释放其访问权。这样一来,其他客户端就能使用 sp_replcmdssp_replshowcmds 扫描事务日志了

 


 

sp_repldone 用于事务复制。

 


 

sp_repldone 由日志读取器进程用来跟踪哪些事务已分发。

使用 sp_repldone,您可以手动通知服务器事务已复制(即已发送到分发服务器)。它还允许您更改被标记为下一个等待复制的事务。您可以在已复制事务的列表中前后移动。(所有小于或等于该事务的事务都将标记为已分发。)

可以使用 sp_repltranssp_replcmds 获得所需的参数 xactidxact_seqno

 


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值