summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2014-02-18 13:54:49 -0500
committerScott Hernandez <scotthernandez@gmail.com>2014-02-18 17:17:59 -0500
commit3042939e0f64bbb9076eef3ee1efcdd56fc02050 (patch)
treec7c16daaecb59dce34707352b7d77284a41706e8 /src
parent3a08be3bf2a1a650c97543a448a8ea0c143a89b6 (diff)
downloadmongo-3042939e0f64bbb9076eef3ee1efcdd56fc02050.tar.gz
SERVER-12625: skip oplog entries for no-op fields
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/ops/modifier_object_replace.cpp10
-rw-r--r--src/mongo/db/ops/modifier_object_replace_test.cpp16
-rw-r--r--src/mongo/db/ops/update.cpp10
-rw-r--r--src/mongo/db/ops/update_driver.cpp2
4 files changed, 20 insertions, 18 deletions
diff --git a/src/mongo/db/ops/modifier_object_replace.cpp b/src/mongo/db/ops/modifier_object_replace.cpp
index ffdfa43112d..4748286b9d8 100644
--- a/src/mongo/db/ops/modifier_object_replace.cpp
+++ b/src/mongo/db/ops/modifier_object_replace.cpp
@@ -179,9 +179,13 @@ namespace mongo {
Status status = logBuilder->getReplacementObject(&replacementObject);
if (status.isOK()) {
- BSONObjIterator it(_val);
- while (status.isOK() && it.more())
- status = replacementObject.appendElement(it.next());
+ mutablebson::Element current = _preparedState->doc.root().leftChild();
+ while (current.ok()) {
+ status = replacementObject.appendElement(current.getValue());
+ if (!status.isOK())
+ return status;
+ current = current.rightSibling();
+ }
}
return status;
diff --git a/src/mongo/db/ops/modifier_object_replace_test.cpp b/src/mongo/db/ops/modifier_object_replace_test.cpp
index cc7057cf646..f6c450c68fb 100644
--- a/src/mongo/db/ops/modifier_object_replace_test.cpp
+++ b/src/mongo/db/ops/modifier_object_replace_test.cpp
@@ -106,7 +106,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(mod.obj(), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
TEST(Normal, ComplexDoc){
@@ -123,7 +123,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(mod.obj(), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
TEST(Normal, OnlyIdField){
@@ -140,7 +140,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(mod.obj(), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
// These updates have to do with updates without an _id field
@@ -159,7 +159,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(mod.obj(), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
TEST(IdLeft, EmptyDoc){
@@ -176,7 +176,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(mod.obj(), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
TEST(IdLeft, SingleFieldAddition){
@@ -193,7 +193,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(mod.obj(), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
TEST(IdLeft, SingleFieldReplaced){
@@ -210,7 +210,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(mod.obj(), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
TEST(IdLeft, SwapFields){
@@ -227,7 +227,7 @@ namespace {
Document logDoc;
LogBuilder logBuilder(logDoc.root());
ASSERT_OK(mod.log(&logBuilder));
- ASSERT_EQUALS(fromjson("{b:1}"), logDoc);
+ ASSERT_EQUALS(doc, logDoc);
}
TEST(IdImmutable, ReplaceIdNumber){
diff --git a/src/mongo/db/ops/update.cpp b/src/mongo/db/ops/update.cpp
index 1c48875fef2..02309ad6eb7 100644
--- a/src/mongo/db/ops/update.cpp
+++ b/src/mongo/db/ops/update.cpp
@@ -730,12 +730,10 @@ namespace mongo {
runner->restoreState());
// Call logOp if requested.
- if (request.shouldCallLogOp()) {
- if (driver->isDocReplacement() || !logObj.isEmpty()) {
- BSONObj idQuery = driver->makeOplogEntryQuery(newObj, request.isMulti());
- logOp("u", nsString.ns().c_str(), logObj , &idQuery,
- NULL, request.isFromMigration(), &newObj);
- }
+ if (request.shouldCallLogOp() && !logObj.isEmpty()) {
+ BSONObj idQuery = driver->makeOplogEntryQuery(newObj, request.isMulti());
+ logOp("u", nsString.ns().c_str(), logObj , &idQuery,
+ NULL, request.isFromMigration(), &newObj);
}
// Only record doc modifications if they wrote (exclude no-ops)
diff --git a/src/mongo/db/ops/update_driver.cpp b/src/mongo/db/ops/update_driver.cpp
index f80b0f40a00..809220a5fa0 100644
--- a/src/mongo/db/ops/update_driver.cpp
+++ b/src/mongo/db/ops/update_driver.cpp
@@ -361,7 +361,7 @@ namespace mongo {
}
// If we require a replication oplog entry for this update, go ahead and generate one.
- if (_logOp && logOpRec) {
+ if (!execInfo.noOp && _logOp && logOpRec) {
status = (*it)->log(&logBuilder);
if (!status.isOK()) {
return status;