惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
M
MIT News - Artificial intelligence
罗磊的独立博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
Security Archives - TechRepublic
Security Archives - TechRepublic
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
The Hacker News
The Hacker News
Google DeepMind News
Google DeepMind News
C
CERT Recently Published Vulnerability Notes
F
Full Disclosure
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Security @ Cisco Blogs
H
Hacker News: Front Page
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
B
Blog RSS Feed
H
Heimdal Security Blog
Google Online Security Blog
Google Online Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 三生石上(FineUI控件)
V2EX - 技术
V2EX - 技术
V
Vulnerabilities – Threatpost
Help Net Security
Help Net Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tailwind CSS Blog
W
WeLiveSecurity
T
Tenable Blog
D
DataBreaches.Net
Martin Fowler
Martin Fowler
Cyberwarzone
Cyberwarzone
Cisco Talos Blog
Cisco Talos Blog
S
Secure Thoughts
O
OpenAI News
L
LINUX DO - 热门话题
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
Jina AI
Jina AI
J
Java Code Geeks
Know Your Adversary
Know Your Adversary
IT之家
IT之家
Latest news
Latest news
Cloudbric
Cloudbric

博客园 - MSSQL123

ubuntu24下 ext4和xfs类型磁盘以及PostgreSQL实例性能对比测试 PostgreSQL 18 新特性 skip scan,一个鸡肋的功能 PostgreSQL 17 流复制中开启逻辑复制槽同步,以及逻辑槽的故障转移 记一次PostgreSQL交叉表crosstab行转列导致的OOM TiDB 扩容与缩容 PostgreSQL 高可用集群 patroni 自动故障转移测试 Ubuntu 20 环境下 patroni 自动化安装,一分钟快速搭建 patroni 集群 Ubuntu 20 环境下 pg_auto_failover 自动化安装,一分钟快速搭建pg_auto_failover集群 PostgreSQL的消息队列扩展pgmq 磁盘IO延迟和队列深度的关系 TiDB 最小拓扑架构集群安装 PostgreSQL 逻辑复制中的同步和异步模式以及其表现 prometheus 的 altermanager Silences静默告警,优雅地抑制告警 “世界上百分之99的博士和他们的论文都是垃圾”,原本以为这个观点偏激 pg_auto_failover 在多种场景下自动故障转移的验证 pgbouncer连接池设置与压力测试的最大连接数测试 pg_auto_failover 自动故障转移参数 博文阅读密码验证 - 博客园 pg_auto_failover 高可用中,PostgreSQL实例配置文件的加载步骤 pg_auto_failover集群monitor节点的高可用 prometheus监控Linux Server node_exporter代理安装和配置 prometheus监控windows window_exporter代理安装和配置 Prometheus 和 Grafana 监控 PostgreSQL 记一次MySQL binlog日志导致磁盘空间占满的问题 SQLServer 2019 标准版在虚拟机上无法充分利用CPU的问题诊断 Windows Failover Cluster集群中的EventId 1196错误日志 pg_auto_failover 环境变量导致的show命令错误 SqlServer 事务复制的两个参数immediate_sync,allow_anonymous MySQL,SqlServer,PostgreSQL中,如何实现锁定一张表 PostgreSQL pg_auto_failover 高可用 2:pg_auto_failover集群运维 PostgreSQL pg_auto_failover 高可用 1:pg_auto_failover集群搭建 PostgreSQL patroni 高可用 4:HAProxy和Keepalived实现读写分离 PostgreSQL patroni 高可用 3:patroni 运维
SqlServer 事务复制(transaction replication)的复制位点信息
MSSQL123 · 2025-10-21 · via 博客园 - MSSQL123

在逻辑复制中,正如MySQL的show slave status,或者postgresql的逻辑复制pg_stat_replication的sent_lsn,来观察复制进度的坐标位点,其复制进度坐标位置都存储在复制的源(source)端。


SqlServer的事务复制则有一些不一样,笔者曾经测试过,多次用不同的备份,对订阅数据库做恢复操作,每次订阅库恢复完之后,都能“完美地”从发布节点复制与当前库的差异数据,那么就有一个值得思考的问题:订阅库的复制位点,或者说复制坐标位置,到底记录在哪里?从这里看,显然是记录在订阅端的,而不是发布端,在发布端和订阅端分别有一个记录复制信息的系统表。

1,在源端,有一个MSdistribution_history系统表存储了复制相关的信息,包括复制的事务号transaction sequence number,复制延迟,复制命令个数等等一些列复制相关的信息,另外有一个时间戳字段,这里含义不明。
2,在目标端,MSreplication_subscriptions,存储了源端的一些信息,其中有一个transaction_timestamp字段,该字段才是真正的复制坐标位点信息,也就意味着,如果订阅节点(从节点)断开后重连,会用这个字段作为起始位置重新开始复制。微软官方并没有明确说明该字段的作用,只是说Internal-use only.

如何证明上述复制坐标位点存在于订阅的目标端而不是发布的服务端?事务分发的数据尚未被清理之前(发布端的distribution库中),笔者尝试过,可以尝试从不同的备份分别恢复订阅库,订阅库总是可以以备份时刻的位点,精确地从分发库获取差异数据。

源端:分发数据库的分发历史表MSdistribution_history 

Column name Data type Description
agent_id int The ID of the Distribution Agent.
runstatus int The Running status:

1 = Start.

2 = Succeed.

3 = In progress.

4 = Idle.

5 = Retry.

6 = Fail.

start_time datetime The time to begin execution of the job.
time datetime The time the message is logged.
duration int The duration, in seconds, of the message session.
comments nvarchar(4000) The message text.
xact_seqno varbinary(16) The last processed transaction sequence number.
current_delivery_rate float The average number of commands delivered per second since the last history entry.
current_delivery_latency int The latency between the command entering the distribution database and being applied to the Subscriber since the last history entry. In milliseconds.
delivered_transactions int The total number of transactions delivered in the session.
delivered_commands int The total number of commands delivered in the session.
average_commands int The average number of commands delivered in the session.
delivery_rate float The average delivered commands per second.
delivery_latency int The latency between the command entering the distribution database and being applied to the Subscriber. In milliseconds.
total_delivered_commands bigint The total number of commands delivered since the subscription was created.
error_id int The ID of the error in the MSrepl_error system table.
updateable_row bit Set to 1 if the history row can be overwritten.
timestamp timestamp The timestamp column of this table.

目标端:订阅端数据库中的订阅表MSreplication_subscriptions

Column name Data type Description
publisher sysname The name of the Publisher.
publisher_db sysname The name of the Publisher database.
publication sysname The name of the publication.
independent_agent bit Indicates whether there is a stand-alone Distribution Agent for this publication.
subscription_type int The type of subscription:

0 = Push.

1 = Pull.

2 = Anonymous.

distribution_agent sysname The name of the Distribution Agent.
Time smalldatetime The time of the last update by Distribution Agent.
description nvarchar(255) The description of the subscription.
transaction_timestamp varbinary(16) Internal-use only.
update_mode tinyint The type of update.
agent_id binary(16) The ID of the agent.
subscription_guid binary(16) The global identifier for the version of the subscription on the publication.
subid binary(16) The global identifier for an anonymous subscription.
immediate_sync bit Indicates whether synchronization files are created or re-created each time the Snapshot Agent runs.