{"id":436612,"date":"2021-04-18T16:43:59","date_gmt":"2021-04-18T08:43:59","guid":{"rendered":"http:\/\/4563.org\/?p=436612"},"modified":"2021-04-18T16:43:59","modified_gmt":"2021-04-18T08:43:59","slug":"%e4%bd%a0%e4%bb%ac%e6%98%af%e6%80%8e%e4%b9%88%e5%a4%84%e7%90%86-mongodb-%e7%9a%84-writeconflict-%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=436612","title":{"rendered":"\u4f60\u4eec\u662f\u600e\u4e48\u5904\u7406 MongoDB \u7684 WriteConflict \u7684\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4f60\u4eec\u662f\u600e\u4e48\u5904\u7406 MongoDB \u7684 WriteConflict \u7684\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5982javascript &#8211; A lot of WriteConflict errors with MongoDB transactions &#8211; Stack Overflow\u4e2d\u6240\u793a\uff0c\u5047\u8bbe\u4e00\u4e2a\u4e8b\u52a1\u6240\u505a\u7684\u64cd\u4f5c\u662f\u201cread-modify-write\u201d\uff0c\u90a3\u4e48\u5728\u591a\u7ebf\u7a0b\u7684\u73af\u5883\u4e0b\u4f1a\u51fa\u73b0 WriteConflict \u3002\u5b83\u4ecb\u7ecd\u4e86\u4e24\u79cd\u89e3\u51b3\u65b9\u6848\uff0c\u4e00\u79cd\u662f\u6392\u961f\u7cfb\u7edf\uff0c\u53e6\u4e00\u79cd\u662f\u91cd\u65b0\u8fd0\u884c\u7cfb\u7edf\u3002\u4e2a\u4eba\u89c9\u5f97\u91cd\u65b0\u8fd0\u884c\u7cfb\u7edf\u662f\u4e0d\u9002\u5408\u5728\u7ade\u4e89\u6fc0\u70c8\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u7684\uff0c\u90a3\u6837\u53ea\u80fd\u8ba9\u60c5\u51b5\u53d8\u5f97\u66f4\u7cdf\u3002\u60f3\u95ee\u4e00\u4e0b\u5927\u5bb6\u662f\u600e\u4e48\u5904\u7406 MongoDB \u7684 WriteConflict \u7684\uff1f<\/p>\n<h2>\u989d\u5916\u9605\u8bfb<\/h2>\n<ul>\n<li>Limitations in MongoDB Transactions &#8211; Database Trends and Applications<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>7<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5676578\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guyeu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u907f\u514d WriteConflict \uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5676579\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @guyeu #1 \u6392\u961f\u7cfb\u7edf\u5176\u5b9e\u5c31\u662f\u907f\u514d\u7684\u4e00\u79cd\u65b9\u6cd5\uff0c\u800c\u91cd\u65b0\u8fd0\u884c\u7cfb\u7edf\u66f4\u50cf\u662f\u201c\u5728\u907f\u514d\u4e0d\u4e86\u6216\u8005\u4e0d\u907f\u514d\u7684\u60c5\u51b5\u4e0b\uff0c\u5e94\u8be5\u600e\u4e48\u505a\u201d\u3002\u4f46\u662f\u5728\u7ade\u4e89\u6fc0\u70c8\u7684\u73af\u5883\u4e0b\uff0c\u91cd\u65b0\u8fd0\u884c\u7cfb\u7edf\u771f\u7684\u662f\u79cd\u597d\u7684\u89e3\u51b3\u65b9\u6848\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5676580\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Nillouise <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8ddf arp \u89e3\u51b3\u51b2\u7a81\u601d\u8def\u90a3\u6837\uff0c\u91cd\u65b0\u8fd0\u884c\u7cfb\u7edf\u9700\u8981\u7b49\u5f85\u4e00\u4e2a\u968f\u673a\u65f6\u95f4\uff0c\u600e\u4e48\u6837\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5676581\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guyeu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @JasonLaw #2 \u91cd\u65b0\u8fd0\u884c\u6709\u4e00\u4e2a\u7f3a\u9677\uff0c\u65e0\u6cd5\u9884\u671f\u4e8b\u52a1\u6267\u884c\u7684\u987a\u5e8f\uff0c\u6240\u4ee5\u6211\u66f4\u503e\u5411\u4e8e\u5728\u4e1a\u52a1\u5c42\u9762\u8fdb\u884c\u8bbe\u8ba1\uff0c\u91c7\u7528\u4e00\u4e9b\u624b\u6bb5\uff08\u5305\u62ec\u4e0d\u4ec5\u9650\u4e8e\u5206\u5e03\u5f0f\u9501\uff09\u907f\u514d\u6570\u636e\u5e93\u5c42\u9762\u7684\u5199\u51b2\u7a81\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5676582\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @guyeu #4 \u201c \u91cd\u65b0\u8fd0\u884c\u6709\u4e00\u4e2a\u7f3a\u9677\uff0c\u65e0\u6cd5\u9884\u671f\u4e8b\u52a1\u6267\u884c\u7684\u987a\u5e8f\u201d\u662f\u4ec0\u4e48\u610f\u601d\uff1f\u53ef\u4ee5\u4e3e\u4e2a\u4f8b\u5b50\u89e3\u91ca\u4e00\u4e0b\u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5676583\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guyeu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @JasonLaw #5 \u4f60\u7684\u6587\u7ae0\u5012\u6570\u7b2c\u4e8c\u6bb5<\/p>\n<p>&gt; MongoDB does lock a document that is being modified by a transaction. However, other sessions that attempt to modify that document do not block. Rather, their transaction is aborted, and they are required to retry the transaction. This is potentially wasteful since other operations in the transaction will need to be re-executed, and also results in requests being serviced in a non-deterministic order.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5676584\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : JasonLaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @guyeu #6 \u5176\u5b9e\u201c\u8bf7\u6c42\u88ab\u670d\u52a1\u7684\u987a\u5e8f\u662f\u4e0d\u786e\u5b9a\u7684\u201d\u4f1a\u66f4\u52a0\u51c6\u786e\u4e00\u70b9\u3002<\/p>\n<p>&gt; results in requests being serviced in a non-deterministic order.                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u4eec\u662f\u600e\u4e48\u5904\u7406 MongoDB \u7684&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/436612"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=436612"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/436612\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=436612"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=436612"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=436612"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}