Permalink
Browse files

SERVER-12915 only track modified docs if move or mods affect indices

  • Loading branch information...
1 parent a3d9109 commit 3709484b65d0c153d4d52713e8466b7b3a791233 Hari Khalsa committed Feb 26, 2014
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/mongo/db/ops/update.cpp
@@ -725,9 +725,6 @@ namespace mongo {
}
newObj = oldObj;
- if (updatedLocs) {
- updatedLocs->insert(loc);
- }
}
else {
@@ -740,7 +737,13 @@ namespace mongo {
uassertStatusOK(res.getStatus());
DiskLoc newLoc = res.getValue();
docWasModified = true;
- if (updatedLocs) {
+
+ // If the document moved, we might see it again in a collection scan (maybe it's
+ // a document after our current document).
+ //
+ // If the document is indexed and the mod changes an indexed value, we might see it
+ // again. For an example, see the comment above near declaration of updatedLocs.
+ if (updatedLocs && (newLoc != loc || driver->modsAffectIndices())) {
updatedLocs->insert(newLoc);
}
}

0 comments on commit 3709484

Please sign in to comment.