Details
-
Improvement
-
Resolution: Done
-
Critical - P2
-
None
-
*Location*: http://docs.mongodb.org/master//release-notes/2.6-upgrade/
*User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36
*Screen Resolution*: 1920 x 1080
*repo*: docs
*source*: release-notes/2.6-upgrade
Description
In the step 2 to downgrade from MongoDB 2.5.x user authorization model to MongoDB 2.4 model, it uses bulk upsert to copy content of admin.system.users to admin.system.new_users.
var bulkUpsert = db.getSiblingDB("admin").system.new_users.initializeOrderedBulkOp();
|
|
db.getSiblingDB("admin").system.users.find().forEach(
|
function (userDoc) {
|
bulkUpsert.find( { _id: userDoc._id } ).upsert().replaceOne( userDoc );
|
}
|
);
|
|
var res = bulkUpsert.execute();
|
print(tojson(res));
|
However, in a sharded cluster, it only supports batch sizes of one and w:0 write concern for config writes. So the bulk upsert in step 2 would fail as below:
admin@undefined> var res = bulkUpsert.execute();
|
2014-02-24T10:18:27.245+1100 Error: batch failed, cannot aggregate results: invalid batch request for config write at src/mongo/shell/bulk_api.js:696
|
It looks like we cannot use bulk upsert to copy the content of admin.system.users to admin.system.new_users. We need to update the document to provide another way to do this.