跟踪复制延迟

本文涉及的产品
云数据库 RDS SQL Server,基础系列 2核4GB
RDS SQL Server Serverless,2-4RCU 50GB 3个月
推荐场景:
简介: SQL Server 2005 has lot of new and improved components, and the Tracer Token in replication is one of them.

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

img_7d0599f8f63a73bb8596e17693742070.jpg

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

img_da37e7f7239ef7fc23cf9dadff068c9b.jpg

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

img_01836456bd20a2318b422cb6fdc7036d.jpg

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.

相关实践学习
使用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
目录
相关文章
|
存储 前端开发 数据库
状态持久化:在应用中保留数据和用户体验的关键
在现代应用程序开发中,状态持久化是一个至关重要的概念。它使应用程序能够在不同会话之间保留数据,确保用户在退出应用程序后再次打开时能够恢复到之前的状态。本博客将深入研究状态持久化的核心概念、方法和最佳实践,以提高用户体验并确保数据的安全性。
163 0
|
1月前
|
运维 监控 安全
自动恢复机制在哪些情况下可能无法正常工作,有哪些替代方案?
自动恢复机制在哪些情况下可能无法正常工作,有哪些替代方案?
|
3月前
|
存储 缓存 定位技术
如果遇到网络延迟问题,有哪些方法可以快速解决以保证视频源同步?
如果遇到网络延迟问题,有哪些方法可以快速解决以保证视频源同步?
|
3月前
|
运维 监控 安全
自动恢复机制在哪些情况下可能无法正常工作
自动恢复机制在哪些情况下可能无法正常工作
|
分布式数据库 数据库
复制延迟案例(1)-最终一致性
该案例违反因果律。 想象先生和夫人之间的对话: Mr Mrs,你能看到多远未来? Mrs 通常约10s,Mr.
92 0
|
安全 关系型数据库 MySQL
为什么延迟复制适用于备库数据的紧急恢复?底层原理是什么?
为什么延迟复制适用于备库数据的紧急恢复?底层原理是什么?
120 0
|
存储 SQL Cloud Native
低延迟流复制
在PolarDB云原生架构下,低延迟也发挥了作用的作用。
低延迟流复制
|
Kubernetes Perl 容器
K8S集群优化之修复ServiceEndpoint更新的延迟
几个月前,我在更新 Kubernetes 集群中的 Deployment 时发现了一个很奇怪的连接超时现象,在更新 Deployment 之后的 30 秒到两分钟左右,所有与以该 Deployment作为服务后端的 Service 的连接都会超时或失败。
2077 0
|
存储 Apache 流计算
Flink 1.8.0中的状态生存时间特性:如何自动清理应用程序的状态
在本文中,我们将讨论引入状态生存时间特性的动机并讨论其相关用例。此外,我们还将演示如何使用和配置该特性。同时,我们将会解释Flink如何借用状态生存时间特性在内部管理状态,并对Flink 1.8.0中该功能引入的相关新特性进行一些展示。本文章最后对未来的改进和扩展作了展望。
1580 0
|
关系型数据库 MySQL 缓存
[缺陷分析]半同步下多从库复制异常
本文分析的缺陷是MySQL bug#89370,其主要的现象是:配置半同步(复制)到多个从库,部分从库在一段时间内无法复制数据,但所有复制状态均正常。
下一篇
无影云桌面