{"id":192768,"date":"2020-06-12T08:28:59","date_gmt":"2020-06-12T00:28:59","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=192768"},"modified":"2020-06-01T09:29:38","modified_gmt":"2020-06-01T01:29:38","slug":"3pc-protocol-distributed-system","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/3pc-protocol-distributed-system.html","title":{"rendered":"\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e00\u81f4\u6027\u4e4b3PC\u534f\u8bae\u6d45\u8c08"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5206\u5e03\u5f0f\u7cfb\u7edf\u4e00\u81f4\u6027\u4e13\u9898\u672c\u671f\u8be5\u5199 3PC \u534f\u8bae\u4e86\uff0c\u4e0a\u5468\u592a\u5fd9\u6ca1\u6709\u65f6\u95f4\u66f4\u65b0\uff0c\u5c31\u62ff\u4e86\u4e4b\u524d\u7684\u65e7\u6587\u7ae0\u505a\u4e86\u4e00\u4e9b\u8c03\u6574\u91cd\u53d1\u4e86\u4e00\u4e0b\uff0c\u8fd8\u671b\u5404\u4f4d\u8bfb\u8005\u6d77\u6db5\u3002\u540e\u9762\u5927\u7ea6\u8fd8\u67093\u671f\uff1aPaxos \u534f\u8bae\u3001Raft \u534f\u8bae\u7b49\uff0c\u5148\u9884\u70ed\u4e00\u4e0b\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u00a0\u4e00.\u5199\u5728\u524d\u9762<\/strong><\/strong><\/div>\n \u5206\u5e03\u5f0f\u7cfb\u7edf\u4e00\u81f4\u6027\u4e13\u9898\u672c\u671f\u8be5\u5199 3PC \u534f\u8bae\u4e86\uff0c\u4e0a\u5468\u592a\u5fd9\u6ca1\u6709\u65f6\u95f4\u66f4\u65b0\uff0c\u5c31\u62ff\u4e86\u4e4b\u524d\u7684\u65e7\u6587\u7ae0\u505a\u4e86\u4e00\u4e9b\u8c03\u6574\u91cd\u53d1\u4e86\u4e00\u4e0b\uff0c\u8fd8\u671b\u5404\u4f4d\u8bfb\u8005\u6d77\u6db5\u3002\u540e\u9762\u5927\u7ea6\u8fd8\u67093\u671f\uff1aPaxos \u534f\u8bae\u3001Raft \u534f\u8bae\u7b49\uff0c\u5148\u9884\u70ed\u4e00\u4e0b\u3002\u6e29\u99a8\u63d0\u793a\uff1a\u672c\u7bc7\u6587\u7ae0\u5e76\u4e0d\u4f1a\u67af\u71e5\uff0c\u6362\u4e86\u4e2a\u753b\u56fe\u5de5\u5177\uff0c\u5bf9\u4e8e\u6211\u8fd9\u79cd\u5efa\u7b51\u4e13\u4e1a\u51fa\u8eab\u7684IT\u72d7\u6765\u8bf4\uff0c\u753b\u56fe\u7b80\u76f4\u662f\u6700\u5f00\u5fc3\u7684\u4e8b\u60c5\u4e86\uff0c\u6240\u4ee5\u653e\u5fc3\u770b\u5427!<\/p>\n <\/p>\n \u56fe(\u7f51\u7edc)|\u730e\u6237\u5ea7\u5927\u661f\u4e91<\/p>\n \u4e8c.3PC\u7684\u51fa\u73b0<\/strong><\/strong><\/div>\n \u4e4b\u524d\u6587\u7ae0\u4e2d\u63d0\u5230\u4e86 2PC \u534f\u8bae\u5b58\u5728\u7684\u534f\u8c03\u8005\u5355\u70b9\u3001\u53c2\u4e0e\u8005\u963b\u585e\u8d85\u65f6\u3001\u7f51\u7edc\u5206\u533a\u3001\u5bb9\u9519\u6027\u7b49\u95ee\u9898\uff0c\u8fd9\u4e9b\u5728\u67d0\u4e9b\u7a0b\u5ea6\u4e0a\u662f\u505a\u4f18\u5316\u548c\u8c03\u6574\u7684\uff0c\u5e76\u4e0d\u662f\u81f4\u547d\u95ee\u9898\u3002\u6211\u4eec\u5bf9 2PC \u534f\u8bae\u7684\u5f02\u5e38\u60c5\u51b5\u505a\u4e86\u62c6\u89e3\uff0c\u4f46\u662f\u90a3\u662f\u4e2am*n\u7684\u7ec4\u5408\u95ee\u9898\uff0c\u6211\u4eec\u5c3d\u91cf\u53bb\u5206\u6790\u4e3b\u8981\u77db\u76fe\uff0c\u4e8e\u662f\u53d1\u73b0\u5728\u534f\u8c03\u8005\u548c\u552f\u4e00\u63a5\u6536\u6307\u4ee4\u7684\u53c2\u4e0e\u8005\u90fd\u51fa\u73b0\u4e0d\u53ef\u6062\u590d\u5b95\u673a\u65f6\uff0c\u5373\u4f7f\u540e\u9762\u9009\u4e3e\u4e86\u65b0\u7684\u534f\u8c03\u8005\uff0c\u4ecd\u7136\u53ef\u80fd\u51fa\u73b0\u6570\u636e\u7684\u4e0d\u4e00\u81f4\u6027\u30023PC \u7684\u51fa\u73b0\u53ef\u80fd\u662f\u591a\u79cd\u56e0\u7d20\u4fc3\u6210\u7684\u3002\u4f46\u662f\u57fa\u672c\u4e0a\u53ef\u4ee5\u786e\u5b9a 3PC \u5c06\u5bf9 2PC \u5b58\u5728\u7684\u95ee\u9898\u8fdb\u884c\u4fee\u6b63\u548c\u4f18\u5316\uff0c\u4f46\u662f\u8fd9\u6837\u5e76\u4e0d\u610f\u5473\u7740 3PC \u4e0d\u4f1a\u5f15\u5165\u65b0\u7684\u95ee\u9898\u3002\u672c\u6587\u5c06\u4ece 3PC \u7684\u534f\u8bae\u8fc7\u7a0b\u6765\u9610\u8ff0\u8fd9\u4e24\u5927\u5757\u5185\u5bb9:<\/p>\n <\/p>\n \u4e09. 3PC\u534f\u8bae\u7684\u57fa\u672c\u8fc7\u7a0b<\/strong><\/strong><\/div>\n 3PC\u534f\u8bae Three-Phase-Commit \u53c8\u79f0\u4e09\u9636\u6bb5\u63d0\u4ea4\u534f\u8bae\uff0c\u76f8\u6bd4 2PC \u534f\u8bae\u589e\u52a0\u4e86\u4e00\u4e2a\u9636\u6bb5\uff0c\u56e0\u6b64\u6211\u4eec\u666e\u904d\u628a 3PC \u534f\u8bae\u770b\u4f5c\u662f 2PC \u534f\u8bae\u7684\u6539\u8fdb\u7248\u672c\u30023PC \u534f\u8bae\u5c06 2PC \u534f\u8bae\u7684\u51c6\u5907\u9636\u6bb5\u4e00\u5206\u4e3a\u4e8c\uff0c\u4ece\u800c\u5f62\u6210\u4e86\u4e09\u4e2a\u9636\u6bb5\uff1a<\/p>\n <\/p>\n \u534f\u8c03\u8005\u548c\u53c2\u4e0e\u8005\u7b49\u5f85\u8d85\u65f6\u60c5\u51b5\u5355\u72ec\u8bf4\uff0c\u5148\u770b\u6b63\u5e38\u60c5\u51b5\u7684\u57fa\u672c\u8fc7\u7a0b\uff0c\u8981\u4e0d\u7136\u5bb9\u6613\u6df7\u6dc6\u3002<\/p>\n 3.1 CanCommit\u9636\u6bb5<\/strong><\/strong><\/span><\/div>\n \u57282PC\u51c6\u5907\u9636\u6bb5\u4e2d\uff0c\u534f\u8c03\u8005\u5411\u53c2\u4e0e\u8005\u53d1\u9001\u6307\u4ee4\u540e\uff0c\u53c2\u4e0e\u8005\u5982\u679c\u5177\u5907\u6267\u884c\u6761\u4ef6\uff0c\u5219\u83b7\u53d6\u9501\u5e76\u6267\u884c\u52a8\u4f5c\uff0c\u53ea\u4e0d\u8fc7\u672a\u771f\u6b63\u63d0\u4ea4\uff0c\u53ef\u4ee5\u8ba4\u4e3a\u53c2\u4e0e\u8005\u5c31\u5dee\u4e34\u95e8\u4e00\u811a\u4e86\uff0c\u8fd8\u5f97\u7b49\u534f\u8c03\u8005\u4fe1\u53f7\u3002\u5982\u679c\u662f commit \u4fe1\u53f7\u90a3\u8fd8\u597d\uff0c\u5982\u679c\u662f rollback \u4fe1\u53f7\uff0c\u90a3\u4e48\u5bf9\u4e8e\u4e00\u4e9b\u672c\u5730\u6267\u884c\u4e86\u52a8\u4f5c\u7684\u53c2\u4e0e\u8005\u6765\u8bf4\u767d\u767d\u6d6a\u8d39\u4e86\uff0c\u6240\u4ee5\u4ece\u8fd9\u4e2a\u89d2\u5ea6\u6765\u8bf4\uff0c2PC \u6709\u70b9\u6fc0\u8fdb\u4e86\uff0c\u4f46\u662f\u8fd9\u4e48\u505a\u4e5f\u662f\u6709\u539f\u56e0\u7684\uff0c\u5728\u590d\u6742\u7684\u7f51\u7edc\u73af\u5883\u4e2d\u591a\u4e00\u8f6e\u4ea4\u4e92\u610f\u5473\u7740\u6027\u80fd\u7684\u635f\u8017\u30023PC\u6765\u8bf4\u66f4\u52a0\u5408\u7406\uff0c\u5148\u7531\u534f\u8c03\u8005\u5411\u53c2\u4e0e\u8005\u53d1\u9001\u8be2\u95ee\u4fe1\u53f7\uff0c\u5144\u5f1f\u4eec\u6709\u6863\u671f\u5417??\u7136\u540e\u5f00\u59cb\u6536\u96c6\u53cd\u9988\uff0c\u76f8\u6bd4\u6765\u8bf4\u66f4\u52a0\u8f7b\u91cf\u3002\u8fd9\u4e2a\u9636\u6bb5\u53c2\u4e0e\u8005\u5e76\u4e0d\u771f\u5b9e\u83b7\u53d6\u9501\u5360\u7528\u8d44\u6e90\uff0c\u53ea\u662f\u5bf9\u81ea\u8eab\u6267\u884c\u4e8b\u52a1\u72b6\u6001\u7684\u68c0\u67e5\uff0c\u67e5\u770b\u662f\u5426\u5177\u5907\u6267\u884c\u4e8b\u52a1\u7684\u6761\u4ef6\uff0c\u8fdb\u800c\u56de\u590d\u8be2\u95ee\u3002<\/p>\n \u6839\u636e\u53c2\u4e0e\u8005\u5bf9\u8be2\u95ee\u7684\u53cd\u9988\uff0c\u5728 CanCommit \u9636\u6bb5\u53ef\u80fd\u51fa\u73b0\u7684\u4e24\u60c5\u51b5\uff1a<\/p>\n A.\u6240\u6709\u53c2\u4e0e\u8005\u5747Ready\u7684\u573a\u666f<\/strong><\/strong><\/span><\/div>\n <\/p>\n \u56fe:\u8be2\u95ee\u9636\u6bb5\u6240\u6709\u53c2\u4e0e\u8005\u5747\u5177\u5907\u6267\u884c\u4e8b\u52a1\u6761\u4ef6<\/p>\n B.\u5b58\u5728\u53c2\u4e0e\u8005\u4e0dOK\u7684\u573a\u666f<\/strong><\/strong><\/span><\/div>\n <\/p>\n \u56fe:\u8be2\u95ee\u9636\u6bb5\u5b58\u5728\u4e0d\u5177\u5907\u6761\u4ef6\u7684\u53c2\u4e0e\u8005<\/p>\n 3.2 PreCommit\u9636\u6bb5<\/strong><\/strong><\/span><\/div>\n \u7b2c\u4e8c\u4e2a\u9636\u6bb5\u7684\u5177\u4f53\u52a8\u4f5c\u53d6\u51b3\u4e8e\u7b2c\u4e00\u4e2a\u9636\u6bb5\u7684\u7ed3\u679c\uff0c\u56e0\u6b64\u53ef\u4ee5\u5206\u4e3a\u4e24\u79cd\u60c5\u51b5\uff1a<\/p>\n CanCommit\u9636\u6bb5\u4e00\u81f4\u901a\u8fc7<\/strong><\/strong><\/span><\/div>\n \u5728\u7b2c\u4e00\u9636\u6bb5\u6240\u6709\u53c2\u4e0e\u8005\u90fd Ready\uff0c\u90a3\u4e48\u534f\u8c03\u8005\u5c31\u4f1a\u5411\u53c2\u4e0e\u8005\u53d1\u9001\u672c\u5730\u6267\u884c\u7684\u76f8\u5173\u6307\u4ee4\uff0c\u8fd9\u90e8\u5206\u548c 2PC \u7684\u7b2c\u4e00\u9636\u6bb5\u975e\u5e38\u76f8\u4f3c\uff0c\u53c2\u4e0e\u8005\u6536\u5230\u6307\u4ee4\u540e\u8fdb\u884c\u672c\u5730\u4e8b\u52a1\u6267\u884c\uff0c\u5e76\u8bb0\u5f55\u65e5\u5fd7\uff0c\u5e76\u4e14\u5bf9\u5904\u7406\u7ed3\u679c\u53cd\u9988\u5230\u534f\u8c03\u8005\uff0c\u6765\u505a\u51b3\u7b56\u3002\u8fc7\u7a0b\u4e2d\u53c2\u4e0e\u8005\u53ef\u80fd\u6210\u529f\u6216\u8005\u5931\u8d25\uff0c\u51fa\u73b0\u4e86\u4e24\u79cd\u60c5\u51b5\uff1a<\/p>\n <\/p>\n \u56fe\uff1aPreCommit\u9636\u6bb5\u53c2\u4e0e\u8005\u5747\u53cd\u9988\u6210\u529f<\/p>\n
CanCommit\u9636\u6bb5\u5b58\u5728\u5206\u6b67<\/strong><\/strong><\/span><\/div>\n \u5728\u7b2c\u4e00\u9636\u6bb5\u5982\u679c\u5b58\u5728\u53c2\u4e0e\u8005\u4e0d Ready \u7684\u60c5\u51b5\uff0c\u90a3\u4e48\u534f\u8c03\u8005\u5c31\u4f1a\u53d1\u9001\u4fe1\u53f7\u7ed9\u6240\u6709\u53c2\u4e0e\u8005\uff0c\u544a\u77e5\u672c\u6b21\u4e8b\u52a1\u53d6\u6d88\u4e86\uff0c\u8be5\u5e72\u5565\u5e72\u5565\u5427\uff0c\u5bf9\u53c2\u4e0e\u8005\u6765\u8bf4\u635f\u5931\u5e76\u4e0d\u5927\uff0c\u56e0\u4e3a\u672c\u8d28\u4e0a\u53c2\u4e0e\u8005\u5e76\u6ca1\u6709\u505a\u4ec0\u4e48\u4e8b\u60c5\u3002<\/p>\n <\/p>\n 3.3 DoCommit\u9636\u6bb5<\/strong><\/strong><\/span><\/div>\n \u8fd9\u662f 3PC \u7684\u7b2c\u4e09\u4e2a\u9636\u6bb5\u548c2PC\u7684\u7b2c\u4e8c\u4e2a\u9636\u6bb5\u7c7b\u4f3c\uff0c\u540c\u6837\u7684 DoCommit \u6267\u884c\u5177\u4f53\u52a8\u4f5c\u53d6\u51b3\u4e8e\u7b2c\u4e8c\u9636\u6bb5 PreCommit \u7684\u7ed3\u679c\uff0c\u56e0\u6b64\u4ecd\u7136\u5206\u4e3a\u4e24\u79cd\u60c5\u51b5\uff1a<\/p>\n PreCommit\u9636\u6bb5\u4e00\u81f4\u901a\u8fc7<\/strong><\/strong><\/span><\/div>\n \u5728 PreCommit \u4e4b\u540e\u53c2\u4e0e\u8005\u5168\u90e8\u5b8c\u6210\u672c\u5730\u4e8b\u52a1\u6267\u884c\u4f46\u662f\u6ca1\u6709\u63d0\u4ea4\uff0c\u5e76\u4e14\u90fd\u7ed9\u534f\u8c03\u8005 ACK \u56de\u590d\uff0c\u8fd9\u65f6\u534f\u8c03\u8005\u8ba4\u4e3a\u4e07\u4e8b\u4ff1\u5907\u53ea\u6b20\u4e1c\u98ce\u4e86\uff0c\u5728 DoCommit \u9636\u6bb5\u534f\u8c03\u8005\u5411\u53c2\u4e0e\u8005\u53d1\u9001\u63d0\u4ea4\u6307\u4ee4\uff0c\u53c2\u4e0e\u8005\u6536\u5230\u4e4b\u540e\u5f00\u59cb\u6267\u884c\u672c\u5730\u63d0\u4ea4\uff0c\u5e76\u53cd\u9988\u7ed3\u679c\uff0c\u6700\u7ec8\u5b8c\u6210\u8fd9\u6b21\u4e8b\u52a1\uff0cCool!<\/p>\n <\/p>\n PreCommit\u9636\u6bb5\u5b58\u5728\u5206\u6b67<\/strong><\/strong><\/span><\/div>\n \u534f\u8c03\u8005\u5728\u7b2c\u4e8c\u4e2a\u9636\u6bb5 PreCommit \u6536\u5230\u53c2\u4e0e\u8005\u7684\u53cd\u9988\u540e\uff0c\u53d1\u73b0\u5b58\u5728\u90e8\u5206\u53c2\u4e0e\u8005\u65e0\u6cd5\u6267\u884c\u4e8b\u52a1\u7684\u60c5\u51b5\uff0c\u8fd9\u65f6\u5c31\u51b3\u5b9a\u544a\u8bc9\u5176\u4ed6\u53c2\u4e0e\u8005\u672c\u5730\u56de\u6eda\uff0c\u91ca\u653e\u8d44\u6e90\uff0c\u53d6\u6d88\u672c\u6b21\u4e8b\u52a1\u3002<\/p>\n <\/p>\n \u56db. 3PC\u4e2d\u7684\u8d85\u65f6\u7b56\u7565<\/strong><\/strong><\/div>\n \u6211\u4eec\u524d\u9762\u63d0\u5230 3PC \u8981\u89e3\u51b3 2PC \u7684\u53c2\u4e0e\u8005\u963b\u585e\u8d85\u65f6\u95ee\u9898\uff0c\u57282PC\u4e2d\u53c2\u4e0e\u8005\u6bd4\u8f83\u75f4\u60c5\uff0c\u534f\u8c03\u8005\u4e0d\u7ed9\u4fe1\u53f7\u4f1a\u957f\u65f6\u95f4\u963b\u585e\uff0c\u4e0d\u91ca\u653e\u8d44\u6e90\uff0c\u8fd9\u6837\u522b\u4eba\u4e5f\u6ca1\u6cd5\u5904\u7406\u5176\u4ed6\u4e8b\u60c5\uff0c\u786e\u5b9e\u4e0d\u592a\u597d\uff0c\u770b\u6765 2PC \u8fd8\u662f\u592a\u4f9d\u8d56\u534f\u8c03\u8005\u4e86\u30023PC \u8ba4\u4e3a\u7f51\u7edc\u8d85\u65f6\u662f\u666e\u904d\u53d1\u751f\u7684\u60c5\u51b5\uff0c\u5982\u679c\u53c2\u4e0e\u8005\u5728\u4e00\u79cd\u5927\u6982\u7387\u786e\u5b9a\u7684\u72b6\u6001\u4e0b\u6267\u884c\u4e00\u4e9b\u52a8\u4f5c\u4e5f\u662f\u88ab\u5141\u8bb8\u7684\uff0c\u5c06\u5728\u5916\u519b\u4ee4\u6709\u6240\u4e0d\u53d7\u30023PC \u7684\u8d85\u65f6\u5904\u7406\u53ef\u80fd\u53d1\u751f\u5728 PreCommit \u548c DoCommit \u9636\u6bb5\uff0c\u6765\u770b\u4e2a\u56fe\uff1a<\/p>\n <\/p>\n \u53c2\u4e0e\u8005\u7b49\u5f85 PreCommit \u8d85\u65f6<\/strong><\/strong><\/span><\/div>\n \u534f\u8c03\u8005\u548c\u53c2\u4e0e\u8005\u4e4b\u95f4\u53ef\u80fd\u5b58\u5728\u8f83\u5927\u7684\u7f51\u7edc\u5ef6\u65f6\uff0c\u6216\u8005\u534f\u8c03\u8005\u51fa\u73b0\u6545\u969c\uff0c\u6216\u8005\u51fa\u73b0\u7f51\u7edc\u5206\u533a\u7b49\u60c5\u51b5\uff0c\u53c2\u4e0e\u8005\u5e76\u4e0d\u4f1a\u50bb\u7b49\uff0c\u5728\u8d85\u8fc7\u8bbe\u5b9a\u65f6\u95f4\u4e4b\u540e\uff0c\u53c2\u4e0e\u8005\u5c31\u7ee7\u7eed\u505a\u4e4b\u524d\u7684\u4e8b\u60c5\u4e86\uff0c\u56e0\u4e3a\u597d\u50cf\u88ab\u5927\u54e5\u9e3d\u4e86\uff0c\u53ea\u80fd\u8be5\u5e72\u5565\u5e72\u5565\uff0c\u8fd9\u4e5f\u662f\u6b63\u786e\u7684\u51b3\u7b56\u3002<\/p>\n \u53c2\u4e0e\u8005\u7b49\u5f85 DoCommit \u8d85\u65f6<\/strong><\/strong><\/span><\/div>\n \u5728 CanCommit \u548c PreCommit \u4e4b\u540e\uff0c\u53c2\u4e0e\u8005\u8ba4\u4e3a\u5927\u5bb6\u90fd\u5bf9\u9f50\u4e86\u90fd\u662f\u68d2\u68d2\u7684\uff0c\u5982\u679c\u53c2\u4e0e\u8005\u5728\u8bbe\u5b9a\u65f6\u95f4\u5185\u5e76\u6ca1\u6709\u6536\u5230\u534f\u8c03\u8005\u7684 DoCommit \u6307\u4ee4\uff0c\u90a3\u4e48\u5c31\u672c\u5730\u6267\u884c\u63d0\u4ea4\u5b8c\u6210\u8fd9\u6b21\u4e8b\u52a1\uff0c\u56e0\u4e3a\u53c2\u4e0e\u8005\u63e3\u6d4b\u5927\u54e5\u7684\u610f\u601d\u5927\u6982\u7387\u4e5f\u662f\u8ba9\u6211\u4eec\u63d0\u4ea4\uff0c\u5e72\u7b49\u7740\u4e5f\u4e0d\u662f\u529e\u6cd5\uff0c\u56de\u6eda\u53ef\u80fd\u548c\u5927\u5bb6\u4e0d\u4e00\u6837\uff0c\u6289\u62e9\u4e4b\u4e0b\u53c2\u4e0e\u8005\u9009\u62e9\u63d0\u4ea4\u4e8b\u52a1\u3002<\/p>\n \u534f\u8c03\u8005\u7b49\u5f85\u53cd\u9988\u8d85\u65f6<\/strong><\/strong><\/span><\/div>\n 3PC\u534f\u8c03\u8005\u7684\u7b49\u5f85\u8d85\u65f6\u5904\u7406\u548c2PC\u57fa\u672c\u4e0a\u662f\u4e00\u6837\u7684\uff0c\u65e0\u8bba\u5728\u54ea\u4e2a\u9636\u6bb5\u8d85\u65f6\u90fd\u8ba4\u4e3a\u4e0d\u5177\u5907\u6761\u4ef6\uff0c\u8fdb\u884c abort \u6216\u8005 rollback \u64cd\u4f5c\uff0c\u8fd9\u4e2a\u975e\u5e38\u597d\u7406\u89e3\u3002<\/p>\n \u53ef\u4ee5\u770b\u52303PC\u534f\u8bae\u4e2d\u53c2\u4e0e\u8005\u4e0d\u518d\u8fc7\u5ea6\u4f9d\u8d56\u534f\u8c03\u8005\u7684\u6307\u4ee4\u4fe1\u53f7\uff0c\u800c\u662f\u6709\u4e86\u81ea\u5df1\u7684\u76f8\u5bf9\u72ec\u7acb\u6027\uff0c\u53ef\u4ee5\u6839\u636e\u5f53\u524d\u6240\u5904\u7684\u72b6\u6001\u6765\u8fdb\u884c\u81ea\u6211\u51b3\u7b56\u3002\u907f\u514d\u4e862PC\u4e2d\u7684\u963b\u585e\u7b49\u5f85\u5e26\u6765\u7684\u8d44\u6e90\u6d6a\u8d39\u60c5\u51b5\uff0c\u786e\u5b9e\u662f\u4e2a\u4e0d\u9519\u7684\u4f18\u5316\uff0c\u4f46\u662f\u6211\u4eec\u5e76\u4e0d\u80fd\u5b8c\u5168\u4fdd\u8bc1\u8fd9\u79cd\u4f18\u5316\u5c31\u90fd\u662f\u5b8c\u5168\u6b63\u786e\u7684\u5440!\u6362\u53e5\u8bdd\u8bf43PC\u89e3\u51b3\u4e862PC\u7684bug\uff0c\u4f46\u662f\u4e0d\u4ee3\u88683PC\u6ca1\u6709\u5f15\u5165\u65b0\u7684bug\u3002<\/p>\n \u4e94. 3PC\u534f\u8bae\u7684\u4e00\u4e9b\u5206\u6790<\/strong><\/strong><\/div>\n \u524d\u9762\u6211\u4eec\u8bf4\u52303PC\u534f\u8bae\u7684\u4e00\u4e2a\u91cd\u8981\u4f5c\u7528\u5c31\u662f\u8981\u5bf92PC\u534f\u8bae\u7684\u6539\u8fdb\u548c\u4f18\u5316\uff0c\u4ece\u4e0a\u9762\u7684\u8fc7\u7a0b\u5206\u6790\u53ef\u77e5\u786e\u5b9e\u505a\u4e86\u4e00\u4e9b\u4f18\u5316\uff0c\u4f46\u662f\u4ecd\u7136\u4e0d\u53ef\u907f\u514d\u51fa\u73b0\u4e86\u65b0\u7684\u95ee\u9898\u3002<\/p>\n 5.1 3PC\u7684\u6570\u636e\u4e0d\u4e00\u81f4\u95ee\u9898<\/strong><\/strong><\/span><\/div>\n 2PC\u534f\u8bae\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u6570\u636e\u4e0d\u4e00\u81f4\u95ee\u9898\uff0c\u90a3\u4e483PC\u6709\u6ca1\u6709\u8fd9\u79cd\u95ee\u9898\u5462?\u7b54\u6848\u662f\u6709\uff0c\u6839\u6e90\u662f\u65b0\u52a0\u7684\u53c2\u4e0e\u8005\u8d85\u65f6\u673a\u5236\u3002\u6bd4\u5982\u53c2\u4e0e\u8005A\u56e0\u4e3a\u81ea\u8eab\u7f51\u7edc\u95ee\u9898\uff0c\u5728\u8bbe\u5b9a\u65f6\u95f4\u5185\u672a\u6536\u5230\u534f\u8c03\u8005\u7684\u4fe1\u53f7\uff0c\u8fd9\u65f6\u53c2\u4e0e\u8005A\u57fa\u4e8e\u4e4b\u524d\u7684\u72b6\u6001\u6267\u884c\u4e86Commit\u64cd\u4f5c\uff0c\u63d0\u4ea4\u4e86\u4e8b\u52a1\uff0c\u8fd9\u79cd\u60c5\u51b5\u786e\u5b9e\u4f1a\u53d1\u751f\uff0c\u6839\u636e\u771f\u5b9e\u7684\u534f\u8c03\u8005\u4fe1\u53f7\u662fcommit\u8fd8\u662frollback\u4f1a\u51fa\u73b0\u4e0d\u540c\u7684\u7ed3\u679c\u3002<\/p>\n \u5982\u679c\u534f\u8c03\u8005\u53d1\u9001\u7684\u662fCommit\u6307\u4ee4\uff0c\u5c31\u548c\u53c2\u4e0e\u8005A\u72ec\u81ea\u51b3\u7b56\u7ed3\u679c\u4e00\u81f4\uff0c\u6ca1\u5565\u95ee\u9898\u3002\u5982\u679c\u534f\u8c03\u8005\u5728DoCommit\u9636\u6bb5\u53d1\u9001\u7684\u662frollback\u6307\u4ee4\uff0c\u90a3\u4e48\u8d85\u65f6\u7684\u53c2\u4e0e\u8005A\u7531\u4e8e\u6267\u884c\u4e86\u672c\u5730\u4e8b\u52a1\u63d0\u4ea4\uff0c\u4ece\u800c\u548c\u5176\u4ed6\u6536\u5230\u6307\u4ee4\u6267\u884crollback\u7684\u53c2\u4e0e\u8005\u7684\u6570\u636e\u4e0d\u4e00\u81f4\u3002<\/p>\n <\/p>\n 5.2 \u51b3\u7b56\u72b6\u6001\u7684\u5bf9\u9f50<\/strong><\/strong><\/span><\/div>\n \u6211\u4eec\u77e5\u90532PC\u534f\u8bae\u7684\u51b3\u7b56\u7ed3\u679c\u521d\u59cb\u9636\u6bb5\u53ea\u6709\u51b3\u7b56\u8005\u77e5\u9053\uff0c\u53ea\u6709\u5728\u5b83\u53d1\u9001\u4e86\u51b3\u7b56\u89e3\u51b3\u624d\u6709\u53c2\u4e0e\u8005\u77e5\u9053\uff0c\u8fd9\u6837\u5c31\u5b58\u5728\u51b3\u7b56\u7ed3\u679c\u4e22\u5931\u7684\u60c5\u51b5\u3002\u5047\u5982\u534f\u8c03\u8005\u6302\u6389\uff0c\u65b0\u534f\u8c03\u8005\u53ef\u4ee5\u54a8\u8be2\u6240\u6709\u7684\u53c2\u4e0e\u8005\u6765\u786e\u5b9a\u51b3\u7b56\u72b6\u6001\uff0c\u6839\u636e\u6240\u6709\u53c2\u4e0e\u8005\u7684\u60c5\u51b5\u6765\u786e\u5b9a\uff0c\u4f46\u662f\u4e07\u4e00\u771f\u7406\u638c\u63e1\u5728\u5c11\u6570\u4eba\u624b\u4e2d\u5462?<\/p>\n \u6781\u7aef\u60c5\u51b5\uff1a<\/strong><\/strong><\/span><\/div>\n \u5047\u5982\u670910\u4e2a\u53c2\u4e0e\u8005\uff0c9\u4e2a\u90fd\u662f\u6b63\u5e38\u7684\uff0c1\u4e2a\u72b6\u6001\u672a\u77e5(\u5148\u53eb\u505aA\u5427)\uff0c10\u4e2a\u53c2\u4e0e\u8005\u90fd\u5411\u534f\u8c03\u8005\u53d1\u9001\u4e86\u53cd\u9988\uff0c\u5982\u679cA\u53cd\u9988\u7684\u662fNot Ready\u4fe1\u53f7\uff0c\u5176\u4ed69\u4e2a\u90fd\u662fReady\u4fe1\u53f7\u3002\u534f\u8c03\u8005\u6c47\u603b\u7ed3\u679c\u51b3\u7b56\u51fa\u4e0d\u5177\u5907\u6267\u884c\u6761\u4ef6\uff0c\u5f00\u59cb\u5411\u6240\u6709\u53c2\u4e0e\u8005\u53d1\u9001rollback\uff0c\u6070\u597d\u7b2c\u4e00\u4e2a\u6536\u5230\u4fe1\u53f7\u7684\u662fA\u673a\u5668\uff0c\u534f\u8c03\u8005\u6302\u4e86\uff0cA\u6536\u5230\u4fe1\u53f7\u540e\u4e5f\u6302\u4e86\u3002\u65b0\u7684\u534f\u8c03\u8005\u8be2\u95ee\u4e86\u5176\u4f599\u4e2a\u90fd\u662fOK\uff0c\u65b0\u7684\u534f\u8c03\u8005\u5c31\u8ba4\u4e3a\u5177\u5907\u6761\u4ef6\u4e86\u4ece\u800c\u53d1\u9001Commit\u4fe1\u53f7\uff0c\u8fd9\u6837\u5c31\u51fa\u73b0\u4e86\u4e0d\u4e00\u81f4\u3002<\/p>\n \u8111\u6d1e\u5927\u5f00\uff1a<\/strong><\/strong><\/span><\/div>\n \u8fd9\u4e2a\u8fc7\u7a0b\u548c\u6e05\u5bab\u5267\u4e2d\u7687\u5e1d\u7acb\u50a8\u5f88\u50cf\u561b\uff0c\u7687\u5e1d\u628a\u7ed3\u679c\u6302\u5728\u671d\u5802\u7684\u724c\u533e\u4e4b\u4e0a\uff0c\u5047\u5b9a\u8bcf\u4e66\u6d88\u5931\u4e86\u4e14\u7687\u5e1d\u6302\u4e86\uff0c\u90a3\u4e48\u7ed3\u679c\u5c31\u4e0d\u5f97\u800c\u77e5\u4e86\uff0c\u667a\u56ca\u56e2\u5728\u6ca1\u6709\u79c1\u5fc3\u7684\u524d\u63d0\u4e0b\u5c31\u9700\u8981\u8003\u5bdf\u6240\u6709\u7684\u4faf\u9009\u4eba\u7684\u60c5\u51b5\u6765\u786e\u5b9a\uff0c\u8fd9\u6837\u5c31\u53ef\u80fd\u51fa\u73b0\u4e0d\u4e00\u81f4\u3002<\/p>\n \u51b3\u7b56\u900f\u660e\u5316\uff1a<\/strong><\/strong><\/span><\/div>\n \u57283PC\u4e2d\u4ecd\u7136\u5b58\u5728\u53ea\u67091\u53f0\u673a\u5668\u6536\u5230\u6307\u4ee4\u7136\u540e\u6302\u6389\u7684\u60c5\u51b5\uff0c\u4f46\u662f\u5982\u679c\u51fa\u73b0\u5728\u524d\u7f6e\u9636\u6bb5\uff0c\u5bf9\u6574\u4e2a\u7ed3\u679c\u662f\u6ca1\u6709\u5f71\u54cd\u7684\uff0c\u56e0\u4e3a\u4f1a\u88ab\u53d6\u6d88\u5e76\u4e14\u53c2\u4e0e\u8005\u5e76\u6ca1\u6709\u672c\u5730\u6267\u884c\u3002<\/p>\n \u73b0\u5728\u770b3PC\u7684\u601d\u60f3\u662f\u628a\u505a\u91cd\u5927\u52a8\u4f5c\u65f6\u7684\u51b3\u7b56\u7ed3\u679c\u900f\u660e\u5316\u7edf\u4e00\u5316\uff0c\u4ea7\u751f\u7684\u5f71\u54cd\u4e5f\u5c31\u975e\u5e38\u5c0f\u4e86\uff0c\u56e0\u6b64PreCommit\u9636\u6bb5\u7684\u72b6\u6001\u662f\u660e\u786e\u7684\u3002<\/p>\n \u6211\u4eec\u9700\u8981\u628a\u51b3\u7b56\u7ed3\u679c\u900f\u660e\u5316\uff0c\u8ba9\u6240\u6709\u53c2\u4e0e\u8005\u90fd\u77e5\u9053\u51b3\u7b56\u7ed3\u679c\uff0c3PC\u7684PreCommit\u9636\u6bb5\u5bf9\u9f50\u4e86\u7ed3\u679c\uff0c\u53ea\u8981\u67091\u53f0\u8fd8\u6d3b\u7740\uff0c\u6574\u4e2a\u4e8b\u52a1\u7684\u72b6\u6001\u5c31\u662f\u786e\u5b9a\u7684\uff0c\u6bd5\u7adf\u6240\u6709\u53c2\u4e0e\u8005\u5168\u6302\u7684\u60c5\u51b5\u6982\u7387\u975e\u5e38\u4f4e\u3002<\/p>\n <\/p>\n \u516d.\u5c0f\u7ed3<\/strong><\/strong><\/div>\n 3PC\u534f\u8bae\u662f\u5bf92PC\u534f\u8bae\u7684\u4f18\u5316\u548c\u6539\u8fdb\uff0c\u901a\u8fc7\u5c062PC\u7684\u51c6\u5907\u9636\u6bb5\u4e00\u5206\u4e3a\u4e8c\uff1aCanCommit\u548cPreCommit\uff0c\u6574\u4e2a\u8fc7\u7a0b\u4e2d\u4e0b\u4e00\u9636\u6bb5\u7684\u6d41\u8f6c\u8981\u53d6\u51b3\u4e8e\u4e0a\u4e00\u4e2a\u9636\u6bb5\u7684\u7ed3\u679c\uff0c\u6d41\u8f6c\u7b80\u56fe\uff1a<\/p>\n <\/p>\n \u7ecf\u8fc7CanCommit\u548cPreCommit\u9636\u6bb5\u540e\uff0c\u53c2\u4e0e\u8005\u4e4b\u95f4\u5bf9\u9f50\u5e76\u4fdd\u7559\u4e86\u51b3\u7b56\u7ed3\u679c\uff0c\u907f\u514d2PC\u534f\u8bae\u6781\u7aef\u60c5\u51b5\u51b3\u7b56\u7ed3\u679c\u7684\u9519\u8bef\u7f3a\u5931\uff0c\u662f\u4e2a\u6bd4\u8f83\u597d\u7684\u505a\u6cd5\u3002<\/p>\n 2PC\u534f\u8bae\u53ea\u6709\u534f\u8c03\u8005\u6709\u8d85\u65f6\u673a\u5236\uff0c3PC\u534f\u8bae\u5bf9\u53c2\u4e0e\u8005\u4e5f\u5f15\u5165\u4e86\u8d85\u65f6\u673a\u5236\uff0c\u5728\u4e0d\u540c\u7684\u9636\u6bb5\u8fdb\u884c\u4e0d\u540c\u7684\u8d85\u65f6\u5904\u7406\uff0c\u4f46\u662f\u7531\u4e8e\u7f51\u7edc\u6ce2\u52a8\u548c\u7f51\u7edc\u5206\u533a\u5b58\u5728\u8ba9\u53c2\u4e0e\u8005\u7684\u8d85\u65f6\u5904\u7406\u5e26\u6765\u65b0\u7684\u4e0d\u786e\u5b9a\u6027\uff0c\u751a\u81f3\u53ef\u80fd\u51fa\u73b0\u6570\u636e\u4e0d\u4e00\u81f4\u3002<\/p>\n 3PC\u534f\u8bae\u589e\u52a0\u4e00\u8f6e\u8be2\u95ee\u9636\u6bb5\u6240\u4ee5\u6574\u4e2a\u4ea4\u4e92\u8fc7\u7a0b\u6bd42PC\u66f4\u957f\u4e86\uff0c\u6027\u80fd\u76f8\u6bd42PC\u662f\u4f1a\u6709\u4e00\u4e9b\u4e0b\u964d\u7684\uff0c\u4f46\u662f3PC\u534f\u8bae\u5bf9\u4e8e\u7f51\u7edc\u5206\u533a\u7b49\u60c5\u51b5\u4e5f\u5e76\u6ca1\u6709\u5904\u7406\u5730\u5f88\u597d\u3002<\/p>\n \u603b\u4f53\u6765\u8bf4\uff0c3PC\u76f8\u6bd42PC\u505a\u4e86\u5f88\u591a\u6539\u8fdb\u6709\u4e00\u5b9a\u7684\u6548\u679c\uff0c\u4f46\u662f\u4ecd\u7136\u5b58\u5728\u6570\u636e\u4e0d\u4e00\u81f4\u95ee\u9898\uff0c\u8fd8\u9700\u7ee7\u7eed\u52aa\u529b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" \u5206\u5e03\u5f0f\u7cfb\u7edf\u4e00\u81f4\u6027\u4e13\u9898\u672c\u671f\u8be5\u5199 3PC \u534f\u8bae\u4e86\uff0c\u4e0a\u5468\u592a\u5fd9\u6ca1\u6709\u65f6\u95f4\u66f4\u65b0\uff0c\u5c31\u62ff\u4e86\u4e4b\u524d\u7684\u65e7\u6587\u7ae0\u505a\u4e86\u4e00\u4e9b\u8c03\u6574\u91cd\u53d1\u4e86\u4e00\u4e0b\uff0c […]<\/p>\n","protected":false},"author":1898,"featured_media":192784,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[563],"class_list":["post-192768","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread","tag-3pc"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1898"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=192768"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192768\/revisions"}],"predecessor-version":[{"id":192786,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/192768\/revisions\/192786"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/192784"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=192768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=192768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=192768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}} |