summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2019-08-30 18:25:22 +0000
committerevergreen <evergreen@mongodb.com>2019-08-30 18:25:22 +0000
commitfca8f46ebfb94eebb5784ab54eb4bb774101e947 (patch)
tree87c93b1299e3150a29ee49bf14b0fea9b179aea9 /src/mongo/db
parent31960610ac664d0f8cd026ab8481dc7a78edb957 (diff)
downloadmongo-fca8f46ebfb94eebb5784ab54eb4bb774101e947.tar.gz
SERVER-43043 Test applyOps on missing nested fields
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/idempotency_test.cpp15
-rw-r--r--src/mongo/db/repl/initial_syncer.cpp2
-rw-r--r--src/mongo/db/update/modifier_node.cpp8
3 files changed, 20 insertions, 5 deletions
diff --git a/src/mongo/db/repl/idempotency_test.cpp b/src/mongo/db/repl/idempotency_test.cpp
index e76599bc86a..96143015561 100644
--- a/src/mongo/db/repl/idempotency_test.cpp
+++ b/src/mongo/db/repl/idempotency_test.cpp
@@ -197,6 +197,21 @@ TEST_F(RandomizedIdempotencyTest, CheckUpdateSequencesAreIdempotent) {
runIdempotencyTestCase();
}
+TEST_F(IdempotencyTest, UpdateTwoFields) {
+ ASSERT_OK(
+ ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_RECOVERING));
+
+ ASSERT_OK(runOpInitialSync(createCollection(kUuid)));
+ ASSERT_OK(runOpInitialSync(insert(fromjson("{_id: 1, y: [0]}"))));
+
+ auto updateOp1 = update(1, fromjson("{$set: {x: 1}}"));
+ auto updateOp2 = update(1, fromjson("{$set: {x: 2, 'y.0': 2}}"));
+ auto updateOp3 = update(1, fromjson("{$set: {y: 3}}"));
+
+ auto ops = {updateOp1, updateOp2, updateOp3};
+ testOpsAreIdempotent(ops);
+}
+
} // namespace
} // namespace repl
} // namespace mongo
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp
index c967983377e..8d3fdfec25a 100644
--- a/src/mongo/db/repl/initial_syncer.cpp
+++ b/src/mongo/db/repl/initial_syncer.cpp
@@ -94,7 +94,7 @@ MONGO_FAIL_POINT_DEFINE(initialSyncHangBeforeCreatingOplog);
// Failpoint which stops the applier.
MONGO_FAIL_POINT_DEFINE(rsSyncApplyStop);
-// Failpoint which causes the initial sync function to hang afte cloning all databases.
+// Failpoint which causes the initial sync function to hang after cloning all databases.
MONGO_FAIL_POINT_DEFINE(initialSyncHangAfterDataCloning);
// Failpoint which skips clearing _initialSyncState after a successful initial sync attempt.
diff --git a/src/mongo/db/update/modifier_node.cpp b/src/mongo/db/update/modifier_node.cpp
index dd0341255a3..2ea03766cf5 100644
--- a/src/mongo/db/update/modifier_node.cpp
+++ b/src/mongo/db/update/modifier_node.cpp
@@ -222,10 +222,10 @@ UpdateExecutor::ApplyResult ModifierNode::applyToNonexistentElement(
auto statusWithFirstCreatedElem = pathsupport::createPathAt(
*(updateNodeApplyParams.pathToCreate), 0, applyParams.element, newElement);
if (!statusWithFirstCreatedElem.isOK()) {
- // $set operaions on non-viable paths are ignored when the update came from replication.
- // We do not error because idempotency requires that any other update modifiers must
- // still be applied. For example, consider applying the following updates twice to an
- // initially empty document:
+ // $set operations on non-viable paths are ignored when the update came from
+ // replication. We do not error because idempotency requires that any other update
+ // modifiers must still be applied. For example, consider applying the following updates
+ // twice to an initially empty document:
// {$set: {c: 0}}
// {$set: {'a.b': 0, c: 1}}
// {$set: {a: 0}}