跟踪复制延迟

本文涉及的产品
云数据库 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.

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.

目录
相关文章
|
数据库 Linux Windows
外网访问内网Memcached数据库
外网访问内网Memcached数据库 本地安装了Memcached数据库,只能在局域网内访问,怎样从外网也能访问本地Memcached数据库? 本文将介绍具体的实现步骤。 1. 准备工作 1.1 安装并启动Memcached数据库 默认安装的Memcached数据库端口是11211。
1297 0
|
2天前
|
弹性计算 运维 搜索推荐
三翼鸟携手阿里云ECS g9i:智慧家庭场景的效能革命与未来生活新范式
三翼鸟是海尔智家旗下全球首个智慧家庭场景品牌,致力于提供覆盖衣、食、住、娱的一站式全场景解决方案。截至2025年,服务近1亿家庭,连接设备超5000万台。面对高并发、低延迟与稳定性挑战,全面升级为阿里云ECS g9i实例,实现连接能力提升40%、故障率下降90%、响应速度提升至120ms以内,成本降低20%,推动智慧家庭体验全面跃迁。
|
3天前
|
数据采集 人工智能 自然语言处理
3分钟采集134篇AI文章!深度解析如何通过云无影AgentBay实现25倍并发 + LlamaIndex智能推荐
结合阿里云无影 AgentBay 云端并发采集与 LlamaIndex 智能分析,3分钟高效抓取134篇 AI Agent 文章,实现 AI 推荐、智能问答与知识沉淀,打造从数据获取到价值提炼的完整闭环。
352 91
|
10天前
|
人工智能 自然语言处理 前端开发
Qoder全栈开发实战指南:开启AI驱动的下一代编程范式
Qoder是阿里巴巴于2025年发布的AI编程平台,首创“智能代理式编程”,支持自然语言驱动的全栈开发。通过仓库级理解、多智能体协同与云端沙箱执行,实现从需求到上线的端到端自动化,大幅提升研发效率,重塑程序员角色,引领AI原生开发新范式。
877 156
|
3天前
|
数据采集 缓存 数据可视化
Android 无侵入式数据采集:从手动埋点到字节码插桩的演进之路
本文深入探讨Android无侵入式埋点技术,通过AOP与字节码插桩(如ASM)实现数据采集自动化,彻底解耦业务代码与埋点逻辑。涵盖页面浏览、点击事件自动追踪及注解驱动的半自动化方案,提升数据质量与研发效率,助力团队迈向高效、稳定的智能化埋点体系。(238字)
259 156
|
4天前
|
域名解析 人工智能
【实操攻略】手把手教学,免费领取.CN域名
即日起至2025年12月31日,购买万小智AI建站或云·企业官网,每单可免费领1个.CN域名首年!跟我了解领取攻略吧~
|
11天前
|
机器人 API 调度
基于 DMS Dify+Notebook+Airflow 实现 Agent 的一站式开发
本文提出“DMS Dify + Notebook + Airflow”三位一体架构,解决 Dify 在代码执行与定时调度上的局限。通过 Notebook 扩展 Python 环境,Airflow实现任务调度,构建可扩展、可运维的企业级智能 Agent 系统,提升大模型应用的工程化能力。