0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-28 07:59:02 +01:00

SERVER-17634 do not apply replicated insert operations on missing collections

This commit is contained in:
Benety Goh 2015-03-12 18:08:26 -04:00
parent 4049c8328c
commit a15dbb65ca
4 changed files with 28 additions and 0 deletions

View File

@ -149,6 +149,11 @@ rstest.nodes.forEach(function (node) {
// Verify that applyOps commands propagate.
// NOTE: This section of the test depends on the oplog and roles schemas.
assert.commandWorked(rstest.getMaster().getDB("admin").runCommand({ applyOps: [
{
op: "c",
ns: "admin.$cmd",
o: { create: "system.roles" }
},
{
op: "i",
ns: "admin.system.roles",
@ -176,6 +181,11 @@ assert.commandWorked(rstest.getMaster().getDB("admin").runCommand({ applyOps: [
ns: "admin.$cmd",
o: { dropDatabase: 1 }
},
{
op: "c",
ns: "admin.$cmd",
o: { create: "system.roles" }
},
{
op: "i",
ns: "admin.system.roles",

View File

@ -52,12 +52,24 @@
);
assert.eq(0, t.find().count() , "Non-zero amount of documents in collection to start");
assert.commandFailed(db.adminCommand(
{applyOps: [{"op": "i", "ns": t.getFullName(), "o": {_id: 5, x: 17}}]}
),
"Applying an insert operation on a non-existent collection should fail");
assert.commandWorked(db.createCollection(t.getName()));
var a = db.adminCommand(
{applyOps: [{"op": "i", "ns": t.getFullName(), "o": {_id: 5, x: 17}}]}
);
assert.eq(1, t.find().count() , "Valid insert failed");
assert.eq(true, a.results[0], "Bad result value for valid insert");
a = db.adminCommand(
{applyOps: [{"op": "i", "ns": t.getFullName(), "o": {_id: 5, x: 17}}]}
);
assert.eq(1, t.find().count() , "Duplicate insert failed");
assert.eq(true, a.results[0], "Bad result value for duplicate insert");
var o = {_id: 5, x: 17};
assert.eq(o , t.findOne() , "Mismatching document inserted.");

View File

@ -11,6 +11,8 @@ output = db.output
doc = { _id : 5 , x : 17 };
assert.commandWorked(db.createCollection(output.getName()));
db.oplog.insert( { ts : new Timestamp() , "op" : "i" , "ns" : output.getFullName() , "o" : doc } );
assert.eq( 0 , output.count() , "before" )

View File

@ -498,6 +498,10 @@ namespace {
// do upserts for inserts as we might get replayed more than once
OpDebug debug;
uassert(ErrorCodes::NamespaceNotFound, str::stream() <<
"Failed to apply insert due to missing collection: " << op.toString(),
collection);
// No _id.
// This indicates an issue with the upstream server:
// The oplog entry is corrupted; or