0

MongoDB v3.4.1, run cleanupOrphaned in a loop do not remove all orphaned documents from the shard,is there any prob?

1.use mongoshake migrate mongo sharding ,there is duplicate error ,key is _id ObjectId('59c000000cf2886b58b6c081')

2. db.table.find({'_id': ObjectId('59c000000cf2886b58b6c081')}).count()
result is 2

3.find which one shard have this doc

while read line do echo $line /bin/mongo $line/db << EOF use db db.table.find({'_id': ObjectId('59c000000cf2886b58b6c081')}).count() EOF done

=> there are shard1 and shard5

4.run cleanupOrphaned in a loop in shard1 and shard5

use admin

var nextKey = { }; var result;

while ( nextKey != null ) { result = db.adminCommand( { cleanupOrphaned: "db.table", startingFromKey: nextKey } );

if (result.ok != 1) print("Unable to complete at this time: failure or timeout.")

printjson(result);

nextKey = result.stoppedAtKey; } 5. db.table.find({'_id': ObjectId('59c000000cf2886b58b6c081')}).count()
result is 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.