summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Bosch <geert@mongodb.com>2017-11-16 14:37:20 -0500
committerGeert Bosch <geert@mongodb.com>2018-01-03 15:31:13 -0500
commit6166b5586f4dc6c5ac2cc2aa4c78b60f4c234c2d (patch)
treeb9b8f0841021faffc6da9336b4e360e269331d3b
parent8a1030897ad076b2443827a325fbe9111835ae39 (diff)
downloadmongo-6166b5586f4dc6c5ac2cc2aa4c78b60f4c234c2d.tar.gz
SERVER-32001 Fix unindexing of rollback in unique partial indexes
(cherry picked from commit 07bfb1286cb6d01d8080ab3b39a1c76dd123e002)
-rw-r--r--jstests/noPassthrough/partial_unique_indexes.js49
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp1
2 files changed, 50 insertions, 0 deletions
diff --git a/jstests/noPassthrough/partial_unique_indexes.js b/jstests/noPassthrough/partial_unique_indexes.js
new file mode 100644
index 00000000000..f2498b747ca
--- /dev/null
+++ b/jstests/noPassthrough/partial_unique_indexes.js
@@ -0,0 +1,49 @@
+/**
+ * SERVER-32001: Test that indexing paths for non-unique, partial, unique, partial&unique
+ * crud operations correctly handle WriteConflictExceptions.
+ */
+(function() {
+ "strict";
+
+ var conn = MongoRunner.runMongod();
+ var testDB = conn.getDB("test");
+
+ var t = testDB.jstests_parallel_allops;
+ t.drop();
+
+ t.createIndex({x: 1, _id: 1}, {partialFilterExpression: {_id: {$lt: 500}}, unique: true});
+ t.createIndex({y: -1, _id: 1}, {unique: true});
+ t.createIndex({x: -1}, {partialFilterExpression: {_id: {$gte: 500}}, unique: false});
+ t.createIndex({y: 1}, {unique: false});
+
+ var _id = {
+ "#RAND_INT": [0, 1000]
+ };
+ var ops = [
+ {op: "remove", ns: t.getFullName(), query: {_id}},
+ {op: "update", ns: t.getFullName(), query: {_id}, update: {$inc: {x: 1}}, upsert: true},
+ {op: "update", ns: t.getFullName(), query: {_id}, update: {$inc: {y: 1}}, upsert: true},
+ ];
+
+ var seconds = 5;
+ var parallel = 5;
+ var host = testDB.getMongo().host;
+
+ var benchArgs = {ops, seconds, parallel, host};
+
+ assert.commandWorked(testDB.adminCommand({
+ configureFailPoint: 'WTWriteConflictExceptionForReads',
+ mode: {activationProbability: 0.01}
+ }));
+ assert.commandWorked(testDB.adminCommand(
+ {configureFailPoint: 'WTWriteConflictException', mode: {activationProbability: 0.01}}));
+ res = benchRun(benchArgs);
+ printjson({res});
+
+ assert.commandWorked(
+ testDB.adminCommand({configureFailPoint: 'WTWriteConflictException', mode: "off"}));
+ assert.commandWorked(testDB.adminCommand(
+ {configureFailPoint: 'WTWriteConflictExceptionForReads', mode: "off"}));
+ res = t.validate();
+ assert(res.valid, tojson(res));
+})();
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
index 27ab575387f..d9bb09bf7ab 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
@@ -1097,6 +1097,7 @@ void WiredTigerIndexUnique::_unindex(WT_CURSOR* c,
triggerWriteConflictAtPoint(c);
return;
}
+ invariantWTOK(ret);
WT_ITEM value;
invariantWTOK(c->get_value(c, &value));
BufReader br(value.data, value.size);