08 November,2024 by Rambler
Question: I'm trying to rename a MongoDB collection but getting the following warning :
Cannot perform operation: an index build is currently running for collection
Answer: Use this command from to identify the operation
db.adminCommand( { currentOp: true, $or: [ { op: "command", "command.createIndexes": { $exists: true } }, { op: "none", "msg" : /^Index Build/ } ] } )
You can also use the aggregate function
db.aggregate( [ { $currentOp : { allUsers: true, idleConnections: false } }, { $match : { client: "10.11.33.99", microsecs_running: {$gt: 10000} }}, {$project: { _id:0, host:1, opid:1, secs_running: 1, op:1, ns:1, waitingForLock: 1, numYields: 1 } } ] ).pretty() db.aggregate( [ { $currentOp : { allUsers: true, idleConnections: false } }, { $match : { client: "10.11.33.99" }}, {$project: { _id:0, host:1, opid:1, secs_running: 1, op:1, ns:1, waitingForLock: 1, numYields: 1 } } ] ).pretty() db.aggregate( [ { $currentOp : { allUsers: true, idleConnections: false } }, {$project: { _id:0, client:1,host:1, opid:1, secs_running: 1, op:1, ns:1, waitingForLock: 1, numYields: 1 } } ] ).pretty() db.aggregate( [ { $currentOp : { allUsers: true, idleConnections: false } }, {$project: { _id:0, client:1,host:1, opid:1, secs_running: 1, op:1, ns:1, waitingForLock: 1, numYields: 1 } } ] ).pretty() db.aggregate( [ { $currentOp : { allUsers: true, idleConnections: false } }, { $match : { ns: "mydb.mycollection"}}, {$project: { _id:0, client:1,host:1, command:1,opid:1, secs_running: 1, op:1, ns:1, waitingForLock: 1, numYields: 1 } } ] ).pretty()
Depending on the circumstances it may be necessary to kill the operatoiom
db.currentOp()
db.killOp(74747474)
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |