跟踪复制延迟

本文涉及的产品
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
云数据库 RDS SQL Server,基础系列 2核4GB
简介:

SQL Server 2005 has lot of new and improved components, and the Tracer Token in replication is one of them. It allows us to validate connections and helps in measuring latencies between the publisher, distributor and subscriber(s). This functionality allows an accurate calculation of latencies that ultimately helps in finding which subscriber take more time to receive a change from the publisher than expected.

You may be wondering whether it puts an extra load on your system or if it will slow down replication? The answer is NO because it only writes very small amount of data in transaction log of the publication database.

I used this feature recently in a company where they had transaction replication failures almost every night. The SQL Server wasreporting following errors:

Query timeout expired
The agent failed with a 'Retry' status. Try to run the agent at a later time.

I did not want to just setup just any value for the QueryTimeout without knowing what it should be. So, I setup the Tracer Token feature and ran it for two days. Afterwards I knew what value to use and configured the system accordingly. Today, it is the fourth week using that setting, and it has not failed yet.

This is a wonderful new feature SQL Server 2005 introduced, and here is how you can implement it and start using it today.

Method #1. (Replication Monitor)

Launch Replication Monitor, and then Expand the Server => Select Publication

Click on the Tracer Token Tab in right pane and then click on Insert Tracer as shown below

After SQL Server sends the token through the replication process, it will display Latencies as shown below:

The latency will be recorded when you click on Insert Tracer. Every time you click on Insert Tracer, a new date/time will be added in Dropdown box (Time Inserted). Hence, you can view your latency at any given time using this dropdown box provided you had Inserted a Tracer Token.

The Publisher to Distributor column displays the time elapsed between a transaction committed at the Pulisher and the corresponding command entered in the distribution database.

The Distributor to Subscriber column display the time elapsed before the commit of the transaction at the subscriber.

Limitation of using Replication Monitor

There is a limitation in setting up the Tracer Token using Replication Monitor. The Tracer Token has to be inserted manually and It limits you to viewing one value at a time.

To overcome this limitation, we have another method to accomplish same thing.

Method #2. (Thru SQL Server Agent)

You can automate your tracer token insert using this method. You need to follow the steps below:

  • Create a SQL Server Agent Job on Publisher Server
  • Add a Job Step with the following T-SQL command:

sp_posttracertoken 'xyz' -- substituting xyz for the name of your publication

  • Schedule this Job to run at whatever interval you want to insert a token into your replication process.

How to analyze these tracer values?

This data is stored in the distribution database. There are a few system defined stored procedure available to view the recorded data. They are:

  • sp_helptracertokens - returns data for every tracer token inserted at publisher for specified publication
  • sp_helptracertokenhistory - returns tokenid specific data

But, I have simplified a way to get the data by writing a query mentioned below:

use distribution
GO
select publisher_commit,
       distributor_commit,
       datediff(ss, publisher_commit, distributor_commit) 'Latency bw Pub and Dis',
       subscriber_commit,
       datediff(ss, distributor_commit, subscriber_commit) 'Latency bw Dis and Sub'
 from MSTracer_tokens join MSTracer_history 
    on tracer_id = parent_tracer_id

The result of this query will have the following data:

  • Date and Time when transaction committed at publisher
  • Date and Time when Command for same transaction inserted at Distributor,
  • Time (in Seconds) Elapses to commit data between publisher and distributor
  • Date and Time when transaction committed at Subscriber
  • Time (in Seconds) Elapses to commit data between Distributor and Subscriber.

Conclusion

Tracer Token is excellent feature to measure latencies and validate connections that can be used to validate or set Agent profile settings and/or identify timeout related problem that can cause replication to fail.

分类:  MSSQL


    本文转自 Fanr_Zh 博客园博客,原文链接:http://www.cnblogs.com/Amaranthus/archive/2011/04/20/2023037.html ,如需转载请自行联系原作者



相关实践学习
使用SQL语句管理索引
本次实验主要介绍如何在RDS-SQLServer数据库中,使用SQL语句管理索引。
SQL Server on Linux入门教程
SQL Server数据库一直只提供Windows下的版本。2016年微软宣布推出可运行在Linux系统下的SQL Server数据库,该版本目前还是早期预览版本。本课程主要介绍SQLServer On Linux的基本知识。 相关的阿里云产品:云数据库RDS SQL Server版 RDS SQL Server不仅拥有高可用架构和任意时间点的数据恢复功能,强力支撑各种企业应用,同时也包含了微软的License费用,减少额外支出。 了解产品详情: https://www.aliyun.com/product/rds/sqlserver
相关文章
|
存储 前端开发 数据库
状态持久化:在应用中保留数据和用户体验的关键
在现代应用程序开发中,状态持久化是一个至关重要的概念。它使应用程序能够在不同会话之间保留数据,确保用户在退出应用程序后再次打开时能够恢复到之前的状态。本博客将深入研究状态持久化的核心概念、方法和最佳实践,以提高用户体验并确保数据的安全性。
162 0
|
C#
如何解决在PotPlayer中看视频音画不同步的问题(C#视频可用)
如何解决在PotPlayer中看视频音画不同步的问题(C#视频可用)
1043 0
|
1月前
|
运维 监控 安全
自动恢复机制在哪些情况下可能无法正常工作,有哪些替代方案?
自动恢复机制在哪些情况下可能无法正常工作,有哪些替代方案?
|
3月前
|
存储 缓存 定位技术
如果遇到网络延迟问题,有哪些方法可以快速解决以保证视频源同步?
如果遇到网络延迟问题,有哪些方法可以快速解决以保证视频源同步?
|
3月前
|
运维 监控 安全
自动恢复机制在哪些情况下可能无法正常工作
自动恢复机制在哪些情况下可能无法正常工作
|
Go 数据库
sync.Once-保证运行期间的某段代码只会执行一次
sync.Once-保证运行期间的某段代码只会执行一次
82 0
|
分布式数据库 数据库
复制延迟案例(1)-最终一致性
该案例违反因果律。 想象先生和夫人之间的对话: Mr Mrs,你能看到多远未来? Mrs 通常约10s,Mr.
92 0
|
安全 关系型数据库 MySQL
为什么延迟复制适用于备库数据的紧急恢复?底层原理是什么?
为什么延迟复制适用于备库数据的紧急恢复?底层原理是什么?
120 0
|
存储 测试技术 开发工具
BSTestRunner增加历史执行记录展示和重试功能
之前对于用例的失败重试,和用例的历史测试记录存储展示做了很多的描述呢,但是都是基于各个项目呢,不方便使用,为了更好的使用,我们对这里进行抽离,抽离出来一个单独的模块,集成到BSTestRunner中,以后我们使用BSTestRunner直接就可以使用里面的失败重试和展示历史记录了。
BSTestRunner增加历史执行记录展示和重试功能
|
存储 SQL Cloud Native
低延迟流复制
在PolarDB云原生架构下,低延迟也发挥了作用的作用。
低延迟流复制