【问题标题】:MongoDB stuck creating index with "Index Build: draining writes received during build" messageMongoDB 坚持使用“索引构建:耗尽构建期间收到的写入”消息创建索引
【发布时间】:2020-08-31 12:19:37
【问题描述】:

test 集合中有 4 行:

{ "_id" : ObjectId("5f4ce50e19b13337216dd477"), "test" : 1 }
{ "_id" : ObjectId("5f4ce50e19b13337216dd478"), "test" : 2 }
{ "_id" : ObjectId("5f4ce50e19b13337216dd479"), "test" : 3 }
{ "_id" : ObjectId("5f4ce50e19b13337216dd47a"), "test" : 4 }

运行db.test.createIndex({test:1},{background:1}); 创建索引后,它只是挂起。它至少挂了几个小时。这是我在 db.currentOp() 中找到的关于此操作的内容:

{
    "type" : "op",
    "host" : "HOSTNAME:27017",
    "desc" : "IndexBuildsCoordinatorMongod-13",
    "active" : true,
    "currentOpTime" : "2020-08-31T12:11:13.159+00:00",
    "opid" : 8721867,
    "secs_running" : NumberLong(20),
    "microsecs_running" : NumberLong(20888590),
    "op" : "command",
    "ns" : "test.test",
    "command" : {
        "createIndexes" : "test",
        "indexes" : [
            {
                "v" : 2,
                "key" : {
                    "test" : 1
                },
                "name" : "test_1",
                "background" : 1
            }
        ],
        "lsid" : {
            "id" : UUID("07b43083-8ab9-4bcb-8768-919a3f27655f")
        },
        "$clusterTime" : {
            "clusterTime" : Timestamp(1598875647, 409),
            "signature" : {
                "hash" : BinData(0,"+/YcdPyQriT8RL1LtFUhxe2BtCE="),
                "keyId" : NumberLong("6861636045532823556")
            }
        },
        "$db" : "test"
    },
    "msg" : "Index Build: draining writes received during build",
    "numYields" : 0,
    "locks" : {

    },
    "waitingForLock" : false,
    "lockStats" : {
        "ReplicationStateTransition" : {
            "acquireCount" : {
                "w" : NumberLong(6)
            }
        },
        "Global" : {
            "acquireCount" : {
                "r" : NumberLong(1),
                "w" : NumberLong(4)
            }
        },
        "Database" : {
            "acquireCount" : {
                "r" : NumberLong(1),
                "w" : NumberLong(4)
            }
        },
        "Collection" : {
            "acquireCount" : {
                "r" : NumberLong(1),
                "w" : NumberLong(3),
                "W" : NumberLong(1)
            }
        },
        "Mutex" : {
            "acquireCount" : {
                "r" : NumberLong(4)
            }
        }
    },
    "waitingForFlowControl" : false,
    "flowControlStats" : {
        "acquireCount" : NumberLong(3),
        "timeAcquiringMicros" : NumberLong(1)
    }
}

这个Index Build: draining writes received during build 毫无意义,因为在创建索引期间没有对test 集合进行读/写操作。

此外,索引创建仅在非空集合中挂起。索引在空集合中创建成功。

在这种情况下可能会出现什么问题?我没有想法。

【问题讨论】:

  • 我会使用官方支持渠道报告此问题。

标签: mongodb mongodb-indexes


【解决方案1】:

终于在 MongoDB 团队的帮助下搞定了。 The node can't communicate with itself so it will hang trying to commit the index build. 这就是原因。添加密钥文件解决了这个问题:

rm -f mongo.keyfile
openssl rand -base64 756 > mongo.keyfile
chmod 400 mongo.keyfile
 
bin/mongod --config mongo.conf --keyFile mongo.keyfile

以下是涵盖该主题的 MongoDB 的 Jira 问题的链接: https://jira.mongodb.org/browse/SERVER-50665https://jira.mongodb.org/browse/SERVER-48516

【讨论】:

  • 部分副本宕机也可能导致此问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-04-06
  • 2012-12-09
  • 2014-07-12
  • 2011-03-20
  • 2015-01-06
  • 2019-04-26
  • 1970-01-01
相关资源
最近更新 更多