您现在的位置是:亿华云 > 域名
女朋友问敖丙:什么是分布式事务?
亿华云2025-10-09 03:36:23【域名】4人已围观
简介复制协调者: writeSTART_2PCtolocallog;//开始事务 multicastVOTE_REQUESTtoallparticipants;

复制协调者: write START_2PC tolocal log; //开始事务 multicast VOTE_REQUEST toall participants; //广播通知参与者投票 while notall votes have been collected { wait forany incoming vote; if timeout { //协调者超时 write GLOBAL_ABORT tolocal log; //写日志 multicast GLOBAL_ABORT toall participants; //通知事务中断 exit; } record vote; } //如果所有参与者都ok if all participants sent VOTE_COMMIT and coordinator votes COMMIT { write GLOBAL_COMMIT tolocal log; multicast GLOBAL_COMMIT toall participants; } else { write GLOBAL_ABORT tolocal log; multicast GLOBAL_ABORT toall participants; } 参与者: write INIT tolocal log; //写日志 wait for VOTE_REQUEST from coordinator; if timeout { //等待超时 write VOTE_ABORT tolocal log; exit; } if participant votes COMMIT { write VOTE_COMMIT tolocal log; //记录自己的女朋决策 send VOTE_COMMIT to coordinator; wait for DECISION from coordinator; if timeout { multicast DECISION_REQUEST to other participants; //超时通知 wait until DECISION is received; /* remain blocked*/ write DECISION tolocal log; } if DECISION == GLOBAL_COMMIT write GLOBAL_COMMIT tolocal log; else if DECISION == GLOBAL_ABORT write GLOBAL_ABORT tolocal log; } else { write VOTE_ABORT tolocal log; send VOTE_ABORT to coordinator; } 每个参与者维护一个线程处理其它参与者的亿华云DECISION_REQUEST请求: while true { wait until any incoming DECISION_REQUEST is received; read most recently recorded STATE from the local log; if STATE == GLOBAL_COMMIT send GLOBAL_COMMIT to requesting participant; else if STATE == INIT or STATE == GLOBAL_ABORT; send GLOBAL_ABORT to requesting participant; else skip; /* participant remains blocked */ } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.免费信息发布网
很赞哦!(833)
相关文章
- 一下域名,看有没有显示出你所解析的IP,如果有,就说明解析是生效的;如果没有,就说明解析是不生效的。
- 一篇文章带你了解ListIterator接口
- 在 Flutter 中更快地加载图像资源!
- JavaScript 异步编程指南 - 探索浏览器中的事件循环机制
- 网站页面结构改版,仅是页面样式发生变化,不会对排名、收录有影响;只有涉及到页面URL改变,才会对网站排名、收录有影响。
- 使用 Jekyll 构建你的网站
- 聊聊最近基于 S3 的项目
- ZooKeeper的选举机制和同步机制超详细讲解,面试经常问到!
- 在此期间,他们每天仍在这里卖大米,在理财方面个人感情有待提高。因为现在是收米的最佳时机。
- IBM 工程师一直在为 GRUB 探索可能的 Rust 模块