黄体回声是什么意思| 白垩纪是什么意思| 散漫是什么意思| 大脑供血不足吃什么药最好| 嘎巴拉是什么| 三楼属于五行属什么| 双侧瞳孔缩小见于什么| 胸骨后是什么位置图| 血糖高的人吃什么水果| 36周岁属什么| hpv吃什么提高免疫力| 广西北海有什么好玩的地方| 孩子吃什么容易长高| 摩羯女和什么星座最配| 马吃什么食物| 狗为什么吐舌头| 管状腺瘤是什么病| 红棕色是什么颜色| 补骨脂是什么东西| 53年属什么生肖| 男生为什么要做包皮手术| 吃小米粥有什么好处和坏处| 尿液粉红色是什么原因| 什么什么如生| 什么是避孕套| 火加良念什么| 传媒公司主要做什么| 权倾朝野是什么意思| 舌苔厚腻是什么原因| 经期为什么不能拔牙| 梦见别人家盖房子是什么意思| 伸舌头锻炼有什么好处| 闭口长什么样子| 梦见老人死了又活了是什么意思| 没有料酒用什么去腥| 利尿什么意思| 神隐是什么意思| 脚底干燥是什么原因| 比细菌还小的东西是什么| 平板和ipad有什么区别| 兔子拉稀是什么原因| 别开生面什么意思| 9月14日是什么星座| 锶对人体有什么好处| 胃不好的人适合吃什么水果| 沉香木是什么| 龟皮痒用什么药膏| 兔子吃什么蔬菜| 睡眠不好用什么药调理| 什么时候开始数伏| 利郎男装是什么档次的| 脉搏细是什么原因| 白毫银针是什么茶| 枸杞和什么一起泡水喝最好| 多发性脂肪瘤是什么原因造成的| 天时地利人和什么意思| 肝是什么器官| 舒张压是什么| 给老人过生日送什么礼物好| 孔雀男是什么意思| 胃出血大便是什么颜色| 手脚心发热是什么原因| 梦见吃桃子是什么预兆| hopeshow是什么牌子| 儿童乳房发育挂什么科| 存款准备金率是什么意思| 2024什么年| 上善若水下一句是什么| 做梦梦见别人怀孕是什么意思| 茯茶是什么茶| 荨麻疹是什么样的| 6月16什么星座| 沙棘是什么| 维生素b12有什么用| 55年属什么| 微信拥抱表情什么意思| 马跟什么生肖最配| 杨过是什么生肖| 好久不见是什么意思| 什么是腐女| 舌苔发白是什么症状| 10mg是什么意思| 人心是什么意思| 肌肤甲错是什么意思| 脑死亡是什么原因引起的| 凌晨6点是什么时辰| longines是什么牌子| 当归炖鸡有什么功效| 2016年是什么生肖| 什么色什么流| 10个月的宝宝吃什么辅食最好| 为什么梦不到死去的亲人| 茯苓生长在什么地方| icd医学上是什么意思| 玉米属于什么类食物| 昆虫记是什么类型的书| 至死不渝是什么意思| 包皮过长挂什么科| 横批是什么意思| 八髎区疼是什么原因| 鸭子烧什么配菜好吃| hy什么意思| 鼠标cpi是什么意思| 免疫力是什么| 什么的生活| 发际线高适合什么发型| 什么是水解奶粉| 孕妇脚肿是什么原因| 胸口疼应该挂什么科| 什么牌子的蛋白质粉比较好| 爱情公寓6什么时候上映| 叶酸什么时间段吃最好| 腥辣食物指的是什么| 体检查什么| 铁观音是什么茶类| 抗炎是什么意思| 脂肪肝是什么意思啊| 贫血的人吃什么水果| 裸婚什么意思| 吃什么补充维生素d| 什么叫活佛| 水瓶后面是什么星座| 咳嗽吃什么药好得快| 田七蒸瘦肉有什么功效| 醋是什么颜色| 梦到死人是什么预兆| 16年属什么| 线雕是什么| 心慌心闷是什么原因| 打喷嚏是什么原因| 梦遗太频繁是什么原因造成的| 痛经吃什么止疼药| 大蒜泡酒有什么功效| 讨好的笑是什么笑| 31年属什么生肖| 六零年属什么生肖| 肌酸激酶偏高说明什么| 盆腔炎吃什么消炎药效果好| 心绞痛吃什么药缓解最快| 少帅是什么军衔| 儿童弱视是什么原因引起的| 什么是晶体| 患难见真情是什么意思| 凉粉果什么时候成熟| 全棉和纯棉有什么区别| 锋芒毕露什么意思| 女生什么时候绝经| 有没有什么| 战国时期是什么时候| 湿热体质吃什么食物好| 什么是部首| 为什么说白痰要人命| 婴儿吃什么奶粉好吸收| 仲夏夜是什么时候| 女生喜欢什么姿势| 心肌缺血是什么症状| 口腔扁平苔藓是什么原因造成的| 殊胜的意思是什么| 舌头有黑点是什么原因| 蓝色预警是什么级别| 什么东西快速补血| 什么蔬菜降血压效果最好| 手指甲软薄吃什么补| 艾司唑仑片是什么药| 卵巢多囊样改变是什么意思| 红油抄手是什么| 中老年人补钙吃什么牌子的钙片好| 防晒衣什么颜色最防晒| 粉头是什么意思| 射手女喜欢什么样的男生| 龟苓膏是什么| 单人旁的字有什么| 乳头瘙痒是什么原因| 何炅和谢娜是什么关系| 什么叫五官| 鸾凤和鸣什么意思| 荷兰的国花是什么花| 宝宝病毒感染吃什么药效果好| 中元节是什么节日| ag是什么意思| 西夏国是现在什么地方| 红枣和灰枣有什么区别| 今天什么日子| 97年的属什么生肖| 儿童办护照需要什么证件| 第一次怀孕有什么反应| 自律是什么意思| 保妇康栓治疗什么妇科病| 专升本要考什么| 鸡属相和什么属相最配| save是什么意思| ccc是什么意思| 蔷薇是什么意思| 一什么黑影| 行云流水是什么意思| 办狗证需要什么资料| 处子之身是什么意思| 91岁属什么| 活检是什么检查| 备孕吃什么最容易怀孕| 现在是吃什么水果的季节| 空气炸锅什么牌子好| 超级碗是什么比赛| 蕞是什么意思| 囊肿与肿瘤有什么区别| 也许是什么意思| 腺样体面容是什么意思| 梦见摘杏子是什么意思| 孕妇梦到被蛇咬是什么意思| cini是什么意思| 2021是什么年| 什么是多囊| 为什么早上起来口苦| 味素是什么| 腊肠炒什么菜好吃| 肾盂是什么意思| 儿童过敏性结膜炎用什么眼药水| 胃镜是什么| 什么叫贫血| 惊为天人是什么意思| 猪八戒是什么生肖| 手指甲的月牙代表什么| 为什么磨牙| 糖化血红蛋白高是什么原因| 法益是什么意思| 骨头属于什么垃圾| 属牛的生什么属相的孩子好| 驾校体检都检查什么| 1月24日是什么星座| 肝外胆管扩张什么意思| 郭靖黄蓉是什么电视剧| 教师节给老师送什么礼物| 口苦口干吃什么药| 夏至吃什么传统食物| 阴道松弛吃什么药| 白细胞低要吃什么| chilli是什么意思| 八九年属什么| 扁肉是什么| 什么油适合炒菜| 灌顶是什么意思| 益生菌对人体有什么好处| 7.4是什么星座| 7月17什么星座| 骨髓穿刺是检查什么病| h型高血压是什么意思| 蚊虫叮咬涂什么药| 客之痣是什么意思| lancome是什么牌子的| 老妈子是什么意思| 为什么白醋把纹身洗掉了| 猫肉为什么不能吃| 吃桃子有什么好处| 心心相惜是什么意思| 氟哌酸又叫什么名字| 脚底长鸡眼是什么原因| 砂仁后下是什么意思| 吃什么补维生素D效果最好| 白敬亭原名叫什么| 无创是什么| 晚上睡觉手发麻是什么原因| 游坦之练的什么武功| 豆花是什么| 喝牛奶就拉肚子是什么原因| 百度Jump to content

股权结构成拦路虎? 哈尔滨银行撤回A股申请

From Wikipedia, the free encyclopedia
A typical sequence of a Two-phase commit.
百度 报道称,利雅得一直对2015年世界强国与德黑兰达成的核问题协议持批评态度。

In transaction processing, databases, and computer networking, the two-phase commit protocol (2PC, tupac) is a type of atomic commitment protocol (ACP). It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort (roll back) the transaction. This protocol (a specialised type of consensus protocol) achieves its goal even in many cases of temporary system failure (involving either process, network node, communication, etc. failures), and is thus widely used.[1][2][3] However, it is not resilient to all possible failure configurations, and in rare cases, manual intervention is needed to remedy an outcome. To accommodate recovery from failure (automatic in most cases) the protocol's participants use logging of the protocol's states. Log records, which are typically slow to generate but survive failures, are used by the protocol's recovery procedures. Many protocol variants exist that primarily differ in logging strategies and recovery mechanisms. Though usually intended to be used infrequently, recovery procedures compose a substantial portion of the protocol, due to many possible failure scenarios to be considered and supported by the protocol.

In a "normal execution" of any single distributed transaction (i.e., when no failure occurs, which is typically the most frequent situation), the protocol consists of two phases:

  1. The commit-request phase (or voting phase), in which a coordinator process attempts to prepare all the transaction's participating processes (named participants, cohorts, or workers) to take the necessary steps for either committing or aborting the transaction and to vote, either "Yes": commit (if the transaction participant's local portion execution has ended properly), or "No": abort (if a problem has been detected with the local portion), and
  2. The commit phase, in which, based on voting of the participants, the coordinator decides whether to commit (only if all have voted "Yes") or abort the transaction (otherwise), and notifies the result to all the participants. The participants then follow with the needed actions (commit or abort) with their local transactional resources (also called recoverable resources; e.g., database data) and their respective portions in the transaction's other output (if applicable).

The two-phase commit (2PC) protocol should not be confused with the two-phase locking (2PL) protocol, a concurrency control protocol.

Assumptions

[edit]

The protocol works in the following manner: one node is a designated coordinator, which is the master site, and the rest of the nodes in the network are designated the participants. The protocol assumes that:

  1. there is stable storage at each node with a write-ahead log,
  2. no node crashes forever,
  3. the data in the write-ahead log is never lost or corrupted in a crash, and
  4. any two nodes can communicate with each other.

The last assumption is not too restrictive, as network communication can typically be rerouted. The first two assumptions are much stronger; if a node is totally destroyed then data can be lost.

The protocol is initiated by the coordinator after the last step of the transaction has been reached. The participants then respond with an agreement message or an abort message depending on whether the transaction has been processed successfully at the participant.

Basic algorithm

[edit]

Commit request (or voting) phase

[edit]
  1. The coordinator sends a query to commit message to all participants and waits until it has received a reply from all participants.
  2. The participants execute the transaction up to the point where they will be asked to commit. They each write an entry to their undo log and an entry to their redo log.
  3. Each participant replies with:
either an agreement message (participant votes Yes to commit), if the participant's actions succeeded;
or an abort message (participant votes No to commit), if the participant experiences a failure that will make it impossible to commit.

Commit (or completion) phase

[edit]

Success

[edit]

If the coordinator received an agreement message from all participants during the commit-request phase:

  1. The coordinator sends a commit message to all the participants.
  2. Each participant completes the operation, and releases all the locks and resources held during the transaction.
  3. Each participant sends an acknowledgement to the coordinator.
  4. The coordinator completes the transaction when all acknowledgements have been received.

Failure

[edit]

If any participant votes No during the commit-request phase (or the coordinator's timeout expires):

  1. The coordinator sends a rollback message to all the participants.
  2. Each participant undoes the transaction using the undo log, and releases the resources and locks held during the transaction.
  3. Each participant sends an acknowledgement to the coordinator.
  4. The coordinator undoes the transaction when all acknowledgements have been received.

Message flow

[edit]
Coordinator                                          Participant
                             QUERY TO COMMIT
                 -------------------------------->
                             VOTE YES/NO             prepare*/abort*
                 <-------------------------------
commit*/abort*               COMMIT/ROLLBACK
                 -------------------------------->
                             ACKNOWLEDGEMENT          commit*/abort*
                 <--------------------------------  
end

An * next to the record type means that the record is forced to stable storage.[4]

Disadvantages

[edit]
  1. The greatest disadvantage of the two-phase commit protocol is that it is a blocking protocol.
  2. If the coordinator fails permanently, some participants will never resolve their transactions: After a participant has sent an agreement message as a response to the commit-request message from the coordinator, it will block until a commit or rollback is received.
  3. A two-phase commit protocol cannot dependably recover from a failure of both the coordinator and a cohort member during the commit phase. If only the coordinator had failed, and no cohort members had received a commit message, it could safely be inferred that no commit had happened. If, however, both the coordinator and a cohort member failed, it is possible that the failed cohort member was the first to be notified, and had actually done the commit. Even if a new coordinator is selected, it cannot confidently proceed with the operation until it has received an agreement from all cohort members, and hence must block until all cohort members respond.

Implementing the two-phase commit protocol

[edit]

Common architecture

[edit]

In many cases the 2PC protocol is distributed in a computer network. It is easily distributed by implementing multiple dedicated 2PC components similar to each other, typically named transaction managers (TMs; also referred to as 2PC agents or Transaction Processing Monitors), that carry out the protocol's execution for each transaction (e.g., The Open Group's X/Open XA). The databases involved with a distributed transaction, the participants, both the coordinator and participants, register to close TMs (typically residing on respective same network nodes as the participants) for terminating that transaction using 2PC. Each distributed transaction has an ad hoc set of TMs, the TMs to which the transaction participants register. A leader, the coordinator TM, exists for each transaction to coordinate 2PC for it, typically the TM of the coordinator database. However, the coordinator role can be transferred to another TM for performance or reliability reasons. Rather than exchanging 2PC messages among themselves, the participants exchange the messages with their respective TMs. The relevant TMs communicate among themselves to execute the 2PC protocol schema above, "representing" the respective participants, for terminating that transaction. With this architecture the protocol is fully distributed (does not need any central processing component or data structure), and scales up with number of network nodes (network size) effectively.

This common architecture is also effective for the distribution of other atomic commitment protocols besides 2PC, since all such protocols use the same voting mechanism and outcome propagation to protocol participants.[1][2]

Protocol optimizations

[edit]

Database research has been done on ways to get most of the benefits of the two-phase commit protocol while reducing costs by protocol optimizations[1][2][3] and protocol operations saving under certain system's behavior assumptions.

Presumed abort and presumed commit

[edit]

Presumed abort or Presumed commit are common such optimizations.[2][3][5] An assumption about the outcome of transactions, either commit, or abort, can save both messages and logging operations by the participants during the 2PC protocol's execution. For example, when presumed abort, if during system recovery from failure no logged evidence for commit of some transaction is found by the recovery procedure, then it assumes that the transaction has been aborted, and acts accordingly. This means that it does not matter if aborts are logged at all, and such logging can be saved under this assumption. Typically a penalty of additional operations is paid during recovery from failure, depending on optimization type. Thus the best variant of optimization, if any, is chosen according to failure and transaction outcome statistics.

Tree two-phase commit protocol

[edit]

The Tree 2PC protocol[2] (also called Nested 2PC, or Recursive 2PC) is a common variant of 2PC in a computer network, which better utilizes the underlying communication infrastructure. The participants in a distributed transaction are typically invoked in an order which defines a tree structure, the invocation tree, where the participants are the nodes and the edges are the invocations (communication links). The same tree is commonly utilized to complete the transaction by a 2PC protocol, but also another communication tree can be utilized for this, in principle. In a tree 2PC the coordinator is considered the root ("top") of a communication tree (inverted tree), while the participants are the other nodes. The coordinator can be the node that originated the transaction (invoked recursively (transitively) the other participants), but also another node in the same tree can take the coordinator role instead. 2PC messages from the coordinator are propagated "down" the tree, while messages to the coordinator are "collected" by a participant from all the participants below it, before it sends the appropriate message "up" the tree (except an abort message, which is propagated "up" immediately upon receiving it or if the current participant initiates the abort).

The Dynamic two-phase commit (Dynamic two-phase commitment, D2PC) protocol[2][6] is a variant of Tree 2PC with no predetermined coordinator. It subsumes several optimizations that have been proposed earlier. Agreement messages (Yes votes) start to propagate from all the leaves, each leaf when completing its tasks on behalf of the transaction (becoming ready). An intermediate (non leaf) node sends ready when an agreement message to the last (single) neighboring node from which agreement message has not yet been received. The coordinator is determined dynamically by racing agreement messages over the transaction tree, at the place where they collide. They collide either at a transaction tree node, to be the coordinator, or on a tree edge. In the latter case one of the two edge's nodes is elected as a coordinator (any node). D2PC is time optimal (among all the instances of a specific transaction tree, and any specific Tree 2PC protocol implementation; all instances have the same tree; each instance has a different node as coordinator): By choosing an optimal coordinator D2PC commits both the coordinator and each participant in minimum possible time, allowing the earliest possible release of locked resources in each transaction participant (tree node).

See also

[edit]

References

[edit]
  1. ^ a b c Philip A. Bernstein, Vassos Hadzilacos, Nathan Goodman (1987): Concurrency Control and Recovery in Database Systems, Chapter 7, Addison Wesley Publishing Company, ISBN 0-201-10715-5
  2. ^ a b c d e f Gerhard Weikum, Gottfried Vossen (2001): Transactional Information Systems, Chapter 19, Elsevier, ISBN 1-55860-508-8
  3. ^ a b c Philip A. Bernstein, Eric Newcomer (2009): Principles of Transaction Processing, 2nd Edition Archived 2025-08-07 at the Wayback Machine, Chapter 8, Morgan Kaufmann (Elsevier), ISBN 978-1-55860-623-4
  4. ^ C. Mohan, Bruce Lindsay and R. Obermarck (1986): "Transaction management in the R* distributed database management system",ACM Transactions on Database Systems (TODS), Volume 11 Issue 4, Dec. 1986, Pages 378 - 396
  5. ^ C. Mohan, Bruce Lindsay (1985): "Efficient commit protocols for the tree of processes model of distributed transactions",ACM SIGOPS Operating Systems Review, 19(2), pp. 40-52 (April 1985)
  6. ^ Yoav Raz (1995): "The Dynamic Two Phase Commitment (D2PC) protocol ",Database Theory — ICDT '95, Lecture Notes in Computer Science, Volume 893/1995, pp. 162-176, Springer, ISBN 978-3-540-58907-5
什么样的充电宝不能带上飞机 手指甲发白是什么原因 外阴白斑是什么原因 染发膏用什么能洗掉 怀孕了不想要最好的办法是什么
枸杞加红枣泡水喝有什么功效 眼干是什么原因引起的 香醋和陈醋有什么区别 李逵属什么生肖 TB是什么缩写
为什么会有阴虱子 妾是什么意思 宝五行属什么 颈动脉斑块是什么意思 十1是什么意思
铁是什么颜色 三位一体是什么生肖 10月15号是什么星座的 蓝色配什么颜色好看 无所事事是什么意思
肌张力高吃什么药hcv7jop5ns4r.cn 火把节在每年农历的什么时间举行hcv8jop7ns9r.cn om什么意思hcv8jop7ns3r.cn 喉咙里痰多是什么原因hanqikai.com 手上的线分别代表什么图解hcv8jop8ns8r.cn
两色富足间是什么生肖helloaicloud.com 肺痈是什么意思hcv8jop8ns3r.cn 肿瘤前期出现什么症状hcv9jop8ns0r.cn 七情六欲什么意思luyiluode.com 四风指什么hcv8jop2ns8r.cn
罡是什么意思hcv8jop9ns8r.cn 白羊座是什么性格hcv8jop3ns4r.cn 脾囊肿是什么病严重吗520myf.com 太子是什么生肖hcv9jop6ns8r.cn 仓鼠为什么吃自己的孩子hcv8jop2ns0r.cn
来例假头晕是什么原因hcv8jop3ns5r.cn 渗透压低是什么意思hcv8jop8ns5r.cn 心无什么用hcv8jop3ns5r.cn 避孕药吃多了有什么副作用hcv8jop3ns9r.cn 董事长是什么职位hcv8jop5ns2r.cn
百度