summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2016-02-16 10:13:49 -0500
committerDianna Hohensee <dianna.hohensee@10gen.com>2016-02-18 17:13:59 -0500
commitee31993039163d1b0a055f90a8f76093e694d7dd (patch)
treeb2e30af77f7c421cbda3b03e631d5fd9b0aca5f0 /jstests/replsets
parent16fdea66101dce875cc370314f00bc34dd407bf6 (diff)
downloadmongo-ee31993039163d1b0a055f90a8f76093e694d7dd.tar.gz
SERVER-22239 DuplicateKey Error, update optime to latest after insert failure
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/lastop.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/jstests/replsets/lastop.js b/jstests/replsets/lastop.js
index 4d1b2519cd3..f3eca2ccb3d 100644
--- a/jstests/replsets/lastop.js
+++ b/jstests/replsets/lastop.js
@@ -106,18 +106,31 @@
assert.eq(noOp, twelfthOp);
+ // No-op insert
+ assert.writeOK(m1.getCollection("test.foo").insert({ _id : 5, x : 5 }));
+ var thirteenthOp = m1.getCollection("test.foo").getDB().getLastErrorObj().lastOp;
+
+ assert.writeOK(m2.getCollection("test.foo").insert({ m2 : 991 }));
+ var fourteenthOp = m2.getCollection("test.foo").getDB().getLastErrorObj().lastOp;
+
+ // Hits DuplicateKey error and fails insert -- no-op
+ assert.writeError(m1.getCollection("test.foo").insert({ _id : 5, x : 5 }));
+ noOp = m1.getCollection("test.foo").getDB().getLastErrorObj().lastOp;
+
+ assert.eq(noOp, fourteenthOp);
+
// Test update and delete failures in legacy write mode.
m2.forceWriteMode('legacy');
m1.forceWriteMode('legacy');
m2.getCollection("test.foo").insert({ m2 : 995 });
- var thirteenthOp = m2.getCollection("test.foo").getDB().getLastErrorObj().lastOp;
+ var fifthteenthOp = m2.getCollection("test.foo").getDB().getLastErrorObj().lastOp;
m1.getCollection("test.foo").remove({ m1 : 1 });
noOp = m1.getCollection("test.foo").getDB().getLastErrorObj().lastOp;
- assert.eq(noOp, thirteenthOp);
+ assert.eq(noOp, fifthteenthOp);
m1.getCollection("test.foo").update({ m1 : 1 }, {$set: {m1: 4}});
noOp = m1.getCollection("test.foo").getDB().getLastErrorObj().lastOp;
- assert.eq(noOp, thirteenthOp);
+ assert.eq(noOp, fifthteenthOp);
})();