diff options
author | Martin Bligh <mbligh@mongodb.com> | 2016-02-02 10:57:23 -0500 |
---|---|---|
committer | Martin Bligh <mbligh@mongodb.com> | 2016-02-02 10:57:50 -0500 |
commit | 370634f46633f0fd6d626822d7d75752a34d4f50 (patch) | |
tree | eb331921b85ba0c0e57a5591ef522c932cec4d1c /src/mongo/db/instance.cpp | |
parent | 5f27647953b67151d1b44f68cd94f6cb3052b860 (diff) | |
download | mongo-370634f46633f0fd6d626822d7d75752a34d4f50.tar.gz |
SERVER-22167: Move fixDocuments up earlier in the insert path to ensure it runs
Diffstat (limited to 'src/mongo/db/instance.cpp')
-rw-r--r-- | src/mongo/db/instance.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp index 9333bf79ea5..496590d05b0 100644 --- a/src/mongo/db/instance.cpp +++ b/src/mongo/db/instance.cpp @@ -986,13 +986,6 @@ void insertMultiVector(OperationContext* txn, CurOp& op, vector<BSONObj>::iterator begin, vector<BSONObj>::iterator end) { - for (vector<BSONObj>::iterator it = begin; it != end; it++) { - StatusWith<BSONObj> fixed = fixDocumentForInsert(*it); - uassertStatusOK(fixed.getStatus()); - if (!fixed.getValue().isEmpty()) - *it = fixed.getValue(); - } - try { WriteUnitOfWork wunit(txn); Collection* collection = ctx.db()->getCollection(ns); @@ -1029,6 +1022,13 @@ NOINLINE_DECL void insertMulti(OperationContext* txn, int64_t chunkSize = 0; for (vector<BSONObj>::iterator it = docs.begin(); it != docs.end(); it++) { + StatusWith<BSONObj> fixed = fixDocumentForInsert(*it); + uassertStatusOK(fixed.getStatus()); + if (!fixed.getValue().isEmpty()) + *it = fixed.getValue(); + } + + for (vector<BSONObj>::iterator it = docs.begin(); it != docs.end(); it++) { chunkSize += (*it).objsize(); // Limit chunk size, actual size chosen is a tradeoff: larger sizes are more efficient, // but smaller chunk sizes allow yielding to other threads and lower chance of WCEs |