0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00

SERVER-32001 Fix unindexing of rollback in unique partial indexes

This commit is contained in:
Geert Bosch 2017-11-16 14:37:20 -05:00
parent b6235c8418
commit 07bfb1286c
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,47 @@
/**
* SERVER-32001: Test that indexing paths for non-unique, partial, unique, partial&unique
* crud operations correctly handle WriteConflictExceptions.
*/
(function() {
"strict";
let conn = MongoRunner.runMongod();
let testDB = conn.getDB("test");
let 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});
let _id = {"#RAND_INT": [0, 1000]};
let 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},
];
let seconds = 5;
let parallel = 5;
let host = testDB.getMongo().host;
let 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));
})();

View File

@ -1213,6 +1213,7 @@ void WiredTigerIndexUnique::_unindex(WT_CURSOR* c,
triggerWriteConflictAtPoint(c); triggerWriteConflictAtPoint(c);
return; return;
} }
invariantWTOK(ret);
WT_ITEM value; WT_ITEM value;
invariantWTOK(c->get_value(c, &value)); invariantWTOK(c->get_value(c, &value));
BufReader br(value.data, value.size); BufReader br(value.data, value.size);