diff options
author | Matthew Russotto <matthew.russotto@10gen.com> | 2018-02-15 10:31:16 -0500 |
---|---|---|
committer | Matthew Russotto <matthew.russotto@10gen.com> | 2018-02-15 10:31:16 -0500 |
commit | 15179bd0a5e9bbe5e48a603c08e38bdb1a08a6fa (patch) | |
tree | 774e0926b92f9816632b71a545dd2157c264db5f | |
parent | 3f33ff25297023eab541f2d3d26cc54ffce1bc98 (diff) | |
download | mongo-15179bd0a5e9bbe5e48a603c08e38bdb1a08a6fa.tar.gz |
SERVER-32241 applyOps reports success even when a nested applyOps fails.
-rw-r--r-- | jstests/core/apply_ops1.js | 10 | ||||
-rw-r--r-- | src/mongo/db/catalog/apply_ops.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 7 |
3 files changed, 14 insertions, 7 deletions
diff --git a/jstests/core/apply_ops1.js b/jstests/core/apply_ops1.js index 1770baef860..be6dcd045b5 100644 --- a/jstests/core/apply_ops1.js +++ b/jstests/core/apply_ops1.js @@ -279,6 +279,16 @@ 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.commandFailed( + db.adminCommand({ + applyOps: [{ + "op": "c", + "ns": "admin.$cmd", + "o": {applyOps: [{"op": "i", "ns": t.getFullName(), "o": {_id: 5, x: 17}}]} + }] + }), + "Applying a nested insert operation on a non-existent collection should fail"); + assert.commandWorked(db.createCollection(t.getName())); var a = assert.commandWorked( db.adminCommand({applyOps: [{"op": "i", "ns": t.getFullName(), "o": {_id: 5, x: 17}}]})); diff --git a/src/mongo/db/catalog/apply_ops.cpp b/src/mongo/db/catalog/apply_ops.cpp index 0afea74e776..f55cd849860 100644 --- a/src/mongo/db/catalog/apply_ops.cpp +++ b/src/mongo/db/catalog/apply_ops.cpp @@ -132,7 +132,7 @@ Status applyOps(OperationContext* txn, try { MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN { if (*opType == 'c') { - status = repl::applyCommand_inlock(txn, temp, true); + uassertStatusOK(status = repl::applyCommand_inlock(txn, temp, true)); break; } else { OldClientContext ctx(txn, ns); @@ -148,7 +148,7 @@ Status applyOps(OperationContext* txn, result->append("code", ex.getCode()); result->append("errmsg", ex.what()); result->append("results", ab.arr()); - return Status(ErrorCodes::UnknownError, ""); + return ex.toStatus(); } ab.append(status.isOK()); diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index e642142d195..e7126254e40 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -1033,11 +1033,8 @@ Status applyCommand_inlock(OperationContext* txn, break; } default: - if (_oplogCollectionName == masterSlaveOplogName) { - error() << "Failed command " << o << " on " << nsToDatabaseSubstring(ns) - << " with status " << status << " during oplog application"; - } else if (curOpToApply.acceptableErrors.find(status.code()) == - curOpToApply.acceptableErrors.end()) { + if (curOpToApply.acceptableErrors.find(status.code()) == + curOpToApply.acceptableErrors.end()) { error() << "Failed command " << o << " on " << nsToDatabaseSubstring(ns) << " with status " << status << " during oplog application"; return status; |