MongoDB 删除索引失败

https://www.doubao.com/chat/XXXXXX
这是一条错误提示信息,内容为 “Failed to drop index ‘idx_time ’ cannot perform operation: a background operation is currently running for collection common.task_gps”。
这条提示通常出现在数据库操作环境中,具体含义如下:
- 它试图删除一个名为 “idx_time” 的索引,但操作失败了。
- 失败的原因是有一个后台操作正在对 “common.task_gps” 集合进行处理,导致无法执行删除索引的操作。
解决这个问题的通常方法是:
- 等待正在运行的后台操作完成,然后再尝试删除索引。
- 检查后台操作是否可以暂停或取消,如果可以,先暂停或取消它,然后再执行删除索引的操作。
PRIMARY> db.currentOp()
{
"type": "op",
"host": "mongo-pro01:27017",
"desc": "conn854084",
"connectionId": 854084,
"client": "10.200.200.4:48480",
"appName": "MongoDB Compass",
"clientMetadata": {
"application": {
"name": "MongoDB Compass"
},
"driver": {
"name": "nodejs",
"version": "6.9.0"
},
"platform": "Node.js v20.18.0, LE",
"os": {
"name": "win32",
"architecture": "x64",
"version": "10.0.19044",
"type": "Windows_NT"
}
},
"active": "true",
"currentOpTime": "2024-12-12T09:05:19.775+08:00",
"effectiveUsers": [
{
"user": "admin",
"db": "admin"
}
],
"opid": -1092079124,
"lsid": {
"id": "e1b3b540-6df8-4f01-aae3-f8e57a18a126",
"uid": "O0CMtIVItQN4IsEOsJdrPL8s7jv5xwh5a/A5Qfvs2A8="
},
"secs_running": 1563,
"microsecs_running": 1563557936,
"op": "command",
"ns": "common.task_gps",
"command": {
"createIndexes": "task_gps",
"indexes": [
{
"name": "idx_carNumber_orderDetailCode_time2",
"key": {
"carNumber": 1,
"orderDetailCode": 1,
"time": 1
}
}
],
"lsid": {
"id": "e1b3b540-6df8-4f01-aae3-f8e57a18a126"
},
"$clusterTime": {
"clusterTime": {
"$timestamp": "7447318461987946524"
},
"signature": {
"hash": "k3CVAGYOrXpX9UOCNBE5lVmIGRg=",
"keyId": {
"low": 68,
"high": 1723392170,
"unsigned": false
}
}
},
"$db": "common"
},
"numYields": 0,
"waitingForLatch": {
"timestamp": "2024-12-12T00:39:16.357Z",
"captureName": "FutureResolution"
},
"locks": {},
"waitingForLock": "false",
"lockStats": {
"ParallelBatchWriterMode": {
"acquireCount": {
"r": 3
}
},
"ReplicationStateTransition": {
"acquireCount": {
"w": 4
}
},
"Global": {
"acquireCount": {
"w": 4
}
},
"Database": {
"acquireCount": {
"w": 3
}
},
"Collection": {
"acquireCount": {
"r": 1,
"w": 1,
"W": 1
},
"acquireWaitCount": {
"W": 1
},
"timeAcquiringMicros": {
"W": 2764
}
},
"Mutex": {
"acquireCount": {
"r": 3
}
}
},
"waitingForFlowControl": false,
"flowControlStats": {
"acquireCount": 3,
"timeAcquiringMicros": 4
}
}




