Transaction Replication2:Transaction

1,Database 的 Trasaction Log File 是用于记录Publication的modification log,在Transaction Replication中,Log Reader Agent 读取Publication的标记为Replcation 的 transaction log,传递到 Distributor 的distribution database中存储起来。

Transaction log files are used not only during the recovery of the database, but also by the Log Reader Agent, which uses the log to send the messages to the distribution database during transactional replication.

2,用于同步到 subscription 的Transaction都是commit的。

Modifying Data and the Log Reader Agent

The Log Reader Agent runs at the Distributor; it typically runs continuously, but can also run according to a schedule you establish. 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 Database Engine operations) and identifies any INSERT, UPDATE, and DELETE statements, or other modifications made to the data in transactions that have been marked for replication. Next, the agent copies those transactions in batches 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.

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 purged. Rows still waiting to be replicated are not purged.

Transaction commands are stored in the distribution database until they are propagated to all Subscribers or until the maximum distribution retention period has been reached. Subscribers receive transactions in the same order in which they were applied at the Publisher.

3,The Log Reader Agent
The Log Reader Agent is responsible for tracking the transaction log on the publication database for any changes marked for replication. It then pushes them to the distribution database, where the Distribution Agent then picks up the messages. As such, the Log Reader Agent is scheduled to run continuously. The transaction log is cleared by SQL Server only after all the messages have been delivered to the distribution database.

4,Transaction Log 在distribution db中存储的时间是有限制的,默认的maximum retention period 是72hours。如果在这个period中,Transaction 没有推送到subscription,Distribution cleanup job将会将这些Transaction 清理掉,subscription必须重新初始化(如果只是缺少部分数据,有workaround可以补救,手动同步数据,并重启Subscription)。

The Distribution Database
The Log Reader Agent acts as the facilitator in forwarding and storing messages from the publication to the distribution database.

The transactions are retained in both the MSrepl_commands and MSrepl_transactions tables for a period of up to 72 hours, by default. This means any transactions that have not been delivered to the subscriptions by that time will be cleaned up by the Distribution cleanup job, and the subscriptions will have to be reinitialized.

The publication retention period is 336 hours, by default, and the subscriptions will be deactivated by the Expired subscription cleanup job on the publishing server after that time. After the subscriptions are reactivated, the retention period will have to be re-created and reinitialized.
The history of the commands and the data is stored in the history tables for each of the agents, namely MSdistribution_history, MSlogreader_history, MSqreader_history (for publication with queued updates), and MSsnapshot_history. they are stored for 48 hours by default.

参考文档:

https://msdn.microsoft.com/en-us/library/ms151176(v=sql.110).aspx

Sujoy Paul-Pro SQL Server 2008 Replication-Apress

时间: 2024-11-01 22:34:29

Transaction Replication2:Transaction的相关文章

异常:Transaction not successfully started

异常:org.hibernate.TransactionException: Transaction not successfully started 错误代码: service层 Session session = HibernateUtils.getCurrentSession(); //....数据库操作语句(调用dao层) Transaction tx = session.beginTransaction(); tx.commit(); dao层 Session session = Hi

Transaction Replication1:Subscription PK columns are readonly

在使用Transaction Replication时,Subscriber 端必须是Read Only的 , all data at the Subscriber is “read-only” (transactional replication does not enforce this at the Subscriber),不能更新Subscriber端的数据的主键,否则,某些数据更新操作会失败. 在Transaction Replication中,How Changes Are Prop

yum安装时提示:Transaction Check Error

Transaction Check Error: file /usr/share/man/man5/dhcp-eval.5.gz from install of dhcp-common-12:4.1.1-43.P1.el6.centos.1.i686 conflicts with file from package dhclient-12:4.1.1-12.P1.el6.i686 file /usr/share/man/man5/dhcp-options.5.gz from install of

Entity Framework 6.0 Tutorials(6):Transaction support

Transaction support: Entity Framework by default wraps Insert, Update or Delete operation in a transaction, whenever you execute SaveChanges(). EF starts a new transaction for each operation and completes the transaction when the operation finishes.

yum安装软件时报错: Transaction check error

在yum安装kubelet时发现报错: 解决办法:将报错信息中提到的冲突程序卸载, 然后继续安装,成功 yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes 原文地址:http://blog.51cto.com/xiaoahehe/2345424

Mybatis深入之事务管理

Mybatis之事务管理 简单介绍 Mybatis的事务管理分为两种JdbcTransaction.ManagedTransaction. 当中JdbcTransaction仅仅是对数据库连接Connection的一个包装.内部管理数据库事务还是调用Connection的提交.回滚等事务操作方法.ManagedTransaction更直接.什么也没有做.直接将事务交给外部容器管理. Mybatis事务管理相关类结构图 类概览: 类UML图(典型的简单工厂模式来创建Transaction): Tr

Hibernate学习笔记--核心编程

参考资料:Java Web核心框架 http://blog.csdn.net/lsh6688/article/details/7611950 Part 1.hibernate核心接口层次架构关系 图:hibernate核心接口层次架构关系 上图中,Hibernate的接口大致可以分为以下几种类型: 1. 基本操作类:一些被用户的应用程序调用的,用来完成基本的创建.读取.更新.删除操作以及查询操作的接口.这些接口是Hibernate实现用户程序的商业逻辑的主要接口,它们包括Session.Tran

黑马程序员——Hibernate 相关概念

1.HIbernate支持多种数据库,是一种“跨数据库平台”的ORM框架.使用Hibernate时需要先创建一个Session对话,然后开启Transaction事务.进行数据库读写.提交事务.关闭会话.Hibernate事务也支持回滚. 2.实体类有3种状态,分别是临时状态.持久化状态.分离状态. 临时状态(Transient):对象在保存进数据库之前为临时状态.这时候数据库中没有该对象的信息,该对象的Id属性也为空.如果没有被持久化,程序退出时临时状态的对象信息将会丢失. 持久化状态(Per

Spring WebFlow(一)

摘自http://hengstart.iteye.com/blog/819748 Spring WebFlow的关注点的层次比Sping MVC 或者是 Structs 更高.不只是关注于如何e构建Web界面,更加关注于流程,也就是Flow. 在Spring WebFlow里面,每个Flow都包括了几个步骤,称为‘State’. 每一个步骤里面都有一个View,View里面的事件处理由State来执行.这些事件会触发一些事务,这些事务会根据之前设置好的配置,跳转到其他的State上面去. 在Sp