{"id":21867,"date":"2024-01-02T16:38:21","date_gmt":"2024-01-02T16:38:21","guid":{"rendered":"https:\/\/server.hk\/blog\/21867\/"},"modified":"2024-11-14T10:25:51","modified_gmt":"2024-11-14T02:25:51","slug":"how-to-fix-mongodb-error-code-285-indexbuildalreadyinprogress","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/21867\/","title":{"rendered":"\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u78bc &#8211; 285 &#8211; IndexBuildAlreadyInProgress"},"content":{"rendered":"<h1 id=\"how-to-fix-mongodb-error-code-285-indexbuildalreadyinprogress-ickIcOMVzS\">\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u78bc &#8211; 285 &#8211; IndexBuildAlreadyInProgress<\/h1>\n<p>MongoDB \u662f\u4e00\u500b\u6d41\u884c\u7684 NoSQL \u6578\u64da\u5eab\uff0c\u63d0\u4f9b\u9ad8\u6027\u80fd\u3001\u53ef\u64f4\u5c55\u6027\u548c\u9748\u6d3b\u6027\u3002\u7136\u800c\uff0c\u5c31\u50cf\u5176\u4ed6\u4efb\u4f55\u8edf\u4ef6\u4e00\u6a23\uff0c\u5b83\u53ef\u80fd\u6703\u9047\u5230\u9700\u8981\u89e3\u6c7a\u7684\u932f\u8aa4\u3002\u5176\u4e2d\u4e00\u500b\u932f\u8aa4\u5c31\u662f MongoDB \u932f\u8aa4\u78bc &#8211; 285 &#8211; IndexBuildAlreadyInProgress\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5011\u5c07\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u542b\u7fa9\u4ee5\u53ca\u5982\u4f55\u4fee\u5fa9\u5b83\u3002<\/p>\n<h2 id=\"understanding-the-mongodb-error-code-285-ickIcOMVzS\">\u7406\u89e3 MongoDB \u932f\u8aa4\u78bc &#8211; 285<\/h2>\n<p>MongoDB \u932f\u8aa4\u78bc &#8211; 285 \u7576\u60a8\u5617\u8a66\u5728\u4e00\u500b\u96c6\u5408\u4e0a\u5275\u5efa\u7d22\u5f15\u6642\uff0c\u4f46\u8a72\u96c6\u5408\u4e0a\u5df2\u6709\u7d22\u5f15\u69cb\u5efa\u6b63\u5728\u9032\u884c\u3002\u9019\u4e00\u932f\u8aa4\u7279\u5b9a\u65bc MongoDB\uff0c\u4e26\u4e14\u5728\u57f7\u884c\u5404\u7a2e\u64cd\u4f5c\u6642\u53ef\u80fd\u6703\u9047\u5230\uff0c\u4f8b\u5982\u5275\u5efa\u7d22\u5f15\u3001\u522a\u9664\u7d22\u5f15\u6216\u91cd\u5efa\u7d22\u5f15\u3002<\/p>\n<p>\u7576\u767c\u751f\u6b64\u932f\u8aa4\u6642\uff0cMongoDB \u6703\u8fd4\u56de\u985e\u4f3c\u4ee5\u4e0b\u7684\u932f\u8aa4\u4fe1\u606f\uff1a<\/p>\n<p><code>Index with name: {indexName} already exists with different options<\/code><\/p>\n<h2 id=\"resolving-the-mongodb-error-code-285-ickIcOMVzS\">\u89e3\u6c7a MongoDB \u932f\u8aa4\u78bc &#8211; 285<\/h2>\n<p>\u8981\u4fee\u5fa9 MongoDB \u932f\u8aa4\u78bc &#8211; 285\uff0c\u60a8\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9a5f\u64cd\u4f5c\uff1a<\/p>\n<h3 id=\"1-check-the-index-build-status-ickIcOMVzS\">1. \u6aa2\u67e5\u7d22\u5f15\u69cb\u5efa\u72c0\u614b<\/h3>\n<p>\u7b2c\u4e00\u6b65\u662f\u6aa2\u67e5\u7d22\u5f15\u69cb\u5efa\u7684\u72c0\u614b\u3002\u60a8\u53ef\u4ee5\u5728 MongoDB shell \u4e2d\u904b\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p><code>db.collectionName.getIndexes()<\/code><\/p>\n<p>\u8a72\u547d\u4ee4\u5c07\u8fd4\u56de\u6307\u5b9a\u96c6\u5408\u4e0a\u6240\u6709\u7d22\u5f15\u7684\u5217\u8868\u3002\u67e5\u627e\u662f\u5426\u6709\u4efb\u4f55\u7d22\u5f15\u8207\u60a8\u8981\u5275\u5efa\u7684\u7d22\u5f15\u540c\u540d\u3002\u5982\u679c\u627e\u5230\uff0c\u5247\u8868\u793a\u7d22\u5f15\u69cb\u5efa\u5df2\u5728\u9032\u884c\u4e2d\u3002<\/p>\n<h3 id=\"2-wait-for-the-index-build-to-complete-ickIcOMVzS\">2. \u7b49\u5f85\u7d22\u5f15\u69cb\u5efa\u5b8c\u6210<\/h3>\n<p>\u5982\u679c\u60a8\u767c\u73fe\u6709\u7d22\u5f15\u69cb\u5efa\u5728\u9032\u884c\u4e2d\uff0c\u5247\u9700\u8981\u7b49\u5230\u5176\u5b8c\u6210\u5f8c\u624d\u80fd\u5275\u5efa\u65b0\u7d22\u5f15\u3002MongoDB \u6bcf\u6b21\u6bcf\u500b\u96c6\u5408\u50c5\u5141\u8a31\u4e00\u500b\u7d22\u5f15\u69cb\u5efa\u3002\u6839\u64da\u96c6\u5408\u7684\u5927\u5c0f\u548c\u7d22\u5f15\u7684\u8907\u96dc\u6027\uff0c\u69cb\u5efa\u904e\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u6642\u9593\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 <code>db.currentOp()<\/code> \u547d\u4ee4\u4f86\u76e3\u63a7\u7d22\u5f15\u69cb\u5efa\u7684\u9032\u5ea6\u3002<\/p>\n<h3 id=\"3-retry-creating-the-index-ickIcOMVzS\">3. \u91cd\u8a66\u5275\u5efa\u7d22\u5f15<\/h3>\n<p>\u4e00\u65e6\u7d22\u5f15\u69cb\u5efa\u5b8c\u6210\uff0c\u60a8\u53ef\u4ee5\u91cd\u8a66\u5275\u5efa\u7d22\u5f15\u3002\u8acb\u78ba\u4fdd\u4f7f\u7528\u4e0d\u540c\u7684\u7d22\u5f15\u540d\u7a31\uff0c\u6216\u8005\u5982\u679c\u4e0d\u518d\u9700\u8981\u73fe\u6709\u7d22\u5f15\uff0c\u53ef\u4ee5\u522a\u9664\u5b83\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u522a\u9664\u7d22\u5f15\uff1a<\/p>\n<p><code>db.collectionName.dropIndex(\"indexName\")<\/code><\/p>\n<p>\u522a\u9664\u7d22\u5f15\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u6240\u9700\u7684\u540d\u7a31\u548c\u9078\u9805\u5275\u5efa\u65b0\u7d22\u5f15\u3002<\/p>\n<h2 id=\"conclusion-ickIcOMVzS\">\u7d50\u8ad6<\/h2>\n<p>\u7576\u96c6\u5408\u4e0a\u5df2\u6709\u7d22\u5f15\u69cb\u5efa\u5728\u9032\u884c\u4e2d\u6642\uff0c\u53ef\u80fd\u6703\u51fa\u73fe MongoDB \u932f\u8aa4\u78bc &#8211; 285 &#8211; IndexBuildAlreadyInProgress\u3002\u901a\u904e\u9075\u5faa\u672c\u6587\u6240\u8ff0\u7684\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u89e3\u6c7a\u6b64\u932f\u8aa4\u4e26\u6210\u529f\u5275\u5efa\u6240\u9700\u7684\u7d22\u5f15\u3002\u8acb\u8a18\u5f97\u6aa2\u67e5\u7d22\u5f15\u69cb\u5efa\u72c0\u614b\uff0c\u7b49\u5f85\u5176\u5b8c\u6210\uff0c\u7136\u5f8c\u91cd\u8a66\u5275\u5efa\u7d22\u5f15\u3002\u5982\u679c\u60a8\u9047\u5230\u9032\u4e00\u6b65\u7684\u554f\u984c\uff0c\u8acb\u53c3\u8003 MongoDB \u6587\u6a94\u6216\u5411 MongoDB \u5c08\u5bb6\u5c0b\u6c42\u5354\u52a9\u3002<\/p>\n<p>\u6709\u95dc VPS \u4e3b\u6a5f\u89e3\u6c7a\u65b9\u6848\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8acb\u8a2a\u554f <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4fee\u5fa9 MongoDB \u932f\u8aa4\u78bc&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-21867","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=21867"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21867\/revisions"}],"predecessor-version":[{"id":23476,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/21867\/revisions\/23476"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=21867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=21867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=21867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}