您现在的位置是:亿华云 > 域名

女朋友问敖丙:什么是分布式事务?

亿华云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)