从MSdistribution_history得到已经同步到订阅库的最后一个事务序列号

本文介绍了在SQL Server中,如何通过Logreader Agent和Distribution Agent跟踪并同步事务到订阅库,特别是在使用transactional replication时。Logreader Agent从发布者日志中获取标记为复制的事务,并将它们插入到分布数据库的系统表中。Distribution Agent随后将这些更改分发到订阅者,并在MSdistribution_history表中记录每个已分发的事务序列号。

 

 

With transactional replication, the Logreader Agent invokes the sp_MSadd_replcommands27hp stored procedure to insert the log records from the publisher to the distribution database. The Distribution Agent invokes the sp_MSget_repl_commands stored procedure  to select the commands that will distributes them to the subscriber.

 

The Logreader Agent insert the log records include xact_seqno column to the MSRepl_transactions and MSRepl_commands system table. 

 

The Distribution Agent distributes the data from the MSRepl_commands system table to the subscriber, and insert  a record (into MSdistribution_history )for every  xact_seqno which transaction had been distribute to the suscriber.

 

detial description:

The Log Reader Agent runs either continuously or according to a schedule you establish at the time the publication is created. When executing, the Log Reader Agent first reads the publication transaction log (the same database log used for transaction tracking and recovery during regular SQL Server 2000 operations) and identifies any INSERT, UPDATE, and DELETE statements, or other modifications made to the data transactions that have been marked for replication. Next, the agent batch copies those transactions to the distribution database at the Distributor. The Log Reader Agent uses the internal stored procedure sp_replcmds to get the next set of commands marked for replication from the log. The distribution database then becomes the store-and-forward queue from which changes are sent to Subscribers. Only committed transactions are sent to the distribution database.

There is a one-to-one correspondence between transactions on the Publisher and replication transactions in the distribution database. One transaction stored in MSrepl_transactions can consist of one or more commands and each command can be broken up along a 500-Unicode-character boundary in the MSrepl_commands table. After the entire batch of transactions has been written successfully to the distribution database, it is committed. Following the commit of each batch of commands to the Distributor, the Log Reader Agent calls sp_repldone to mark where replication was last completed. Finally, the agent marks the rows in the transaction log that are ready to be truncated. Rows still waiting to be replicated are not truncated. The transaction log on the Publisher can be dumped without interfering with replication, because only transactions not marked for replication are purged.

 

other web link:

http://www.yesky.com/imagesnew/software/tsql/ts_sp_repl3_7ug5.htm  

http://www.yesky.com/imagesnew/software/tsql/ts_sp_repl3_21df.htm

http://www.yesky.com/imagesnew/software/tsql/ts_sp_repl3_1d2r.htm

 

验证方法

 

declare @newtime nchar(100)
--get last_xact_seqno
select xact_seqno as last_xact_seqno from MSdistribution_history
where agent_id = 6 and timestamp in(select max(timestamp)from MSdistribution_history )

 

set @newtime = convert(nchar(100),getdate(),114)
insert into MARKET_P4116.testDenny.dbo.testTable values (@newtime,'')

select max(xact_seqno) as dist_max_xact from  dbo.MSrepl_transactions

select * from MARKET_P4116.testDenny.dbo.testTable where keyfield = @newtime
select * from [MARKET_P4116/SQL2005DV3].asdf.dbo.testTable where keyfield = @newtime

 

内容概要:本文系统讲解了openEuler内核模块开发的全链路技术体系,涵盖架构原理、环境搭建、代码实现、编译调试、安全加固与生产落地。深入剖析openEuler内核的用户态/内核态隔离机制、模块动态加载原理、国密SM3签名认证、跨架构适配(x86_64/aarch64)等核心技术,通过HelloKernel实例演示模块生命周期管理,并详细阐述Makefile工程化编译、日志调试、Oops异常分析、KGDB源码级调试等关键技能。进一步覆盖内核参数传递、设备文件交互、内存管理、并发同步、中断与定时器等核心功能开发,最后结合系统监控模块综合项目,实现从理论到生产级落地的完整闭环。; 适合人群:具备Linux系统基础和C语言编程能力,从事操作系统、驱动开发或内核安全相关工作的研发人员,尤其是面向国产化平台开发的技术工程师;适合工作2年以上的中级开发者向高级进阶。; 使用场景及目标:①掌握openEuler内核模块在鲲鹏架构下的编译、签名与部署流程;②理解并实现内核级功能扩展如设备驱动、系统监控、安全加固模块;③具备独立完成模块开发、调试、性能调优及多版本兼容的能力,满足政企、工业、云边端等生产环境要求;④符合国家信息安全等级保护与信创合规标准。; 阅读建议:学习过程中应严格匹配openEuler 24.03 LTS环境,结合官方SDK工具链进行实践操作,重点关注国密签名、版本适配与安全规范;建议按章节顺序推进,先掌握基础框架再深入调试与安全机制,最终通过综合项目整合全部技能,反复演练编译排错与异常定位流程。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值