>  기사  >  데이터 베이스  >  如何查看distirbution agent的执行进度

如何查看distirbution agent的执行进度

WBOY
WBOY원래의
2016-06-07 17:42:281052검색

在 transactional replication troubleshooting 的过程中,经常会遇到下面的场景: 客户在发布端执行了一个几百万行的更新,结果导致性能下降。 客户很想知道目前 distribution agent 的进度,完成的百分比,决定是等下去还是跳过这个过程。如果已经完成了 9

transactional replication troubleshooting的过程中,服务器空间,经常会遇到下面的场景:

客户在发布端执行了一个几百万行的更新,结果导致性能下降。 客户很想知道目前distribution agent的进度,香港虚拟主机,完成的百分比,决定是等下去还是跳过这个过程。如果已经完成了90%,那么贸然停止就非常可惜了,并且rollback的操作也是要很长时间的。

   

下面介绍如何查看进度。

对比结果就可以知道进度了。

   

如果没有启用verbose log,就比较麻烦了,下面是具体的步骤。

  • 找到相应的distribution agent 名称和publisher_database_id

    select *From distribution..msdistribution_agents

  • 通过名称就可以找到distribution agent进行的process id. distributor上执行下面的语句。

    select hostprocess from sys.sysprocesses where program_name=@mergeAgentName

  • 同一个distribution agent进程的process id是相同的,所以可以通过这个process id(对应trace里的client process id),免备案空间,使用sql server trace得到distribution agent正在subscriber端执行的语句.
  • 假设我们得到了下面这个语句exec [dbo].[sp_MSupd_dbota] default,511,4,0x02
  • 根据这个存储过程,我们可以得到相应的aritlce_id

  • subscription database 执行sp_helptext,得到表的名称
  • distribution数据库查询得出article_id. select article_id from msarticles where destination_object=@tablename
  • select transaction_timestamp,* From MSreplication_subscriptions where distribution_agent=@distribution_agent

  • 接下来就可找到distribution agent当前正在执行的xact_seqno. 将第一步得到的publisher_database_id,5步得到的article_id和上一步得到的xact_seqno带入下面的查询

    select xact_seqno,count(*) as number From distribution..msrepl_commands with(nolock)

    where publisher_database_id=@publisher_database_id and article_id=@article_id

    xact_seqno>@xact_seqno group by xact_seqno order by xact_seqno

  • 顺序靠前,并且number较大的就是正在执行的事务了。 您可能会问,为什么不是第六步得到的xact_seqno的下一个呢(select min(xact_seqno)From distribution..msrepl_commands with(nolock)where publisher_database_id=@publisher_database_id and xact_seqno>@xact_seqno).

  • 用第四步得到的语句去查找,这样就可以知道当前执行到了什么位置
  • 성명:
    본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.