diff options
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/commands/eval.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/concurrency/write_conflict_exception.h | 5 | ||||
-rw-r--r-- | src/mongo/db/keys_collection_manager_sharding.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/pipeline/close_change_stream_exception.h | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/apply_ops.cpp | 29 | ||||
-rw-r--r-- | src/mongo/db/repl/master_slave.h | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback_no_uuid.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/dur_journal.cpp | 2 |
13 files changed, 48 insertions, 40 deletions
diff --git a/src/mongo/db/commands/eval.cpp b/src/mongo/db/commands/eval.cpp index 68589d6b7b3..6a83aadfcc0 100644 --- a/src/mongo/db/commands/eval.cpp +++ b/src/mongo/db/commands/eval.cpp @@ -214,7 +214,7 @@ public: uasserted(ErrorCodes::BadValue, str::stream() << "can't use sharded collection from db.eval"); } - throw ex; + throw; } } diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index c6ff02b154c..7f39b45a3c9 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -1663,10 +1663,10 @@ public: // *requires* rethrow AssertionExceptions - should probably fix. catch (AssertionException& e) { log() << "mr failed, removing collection" << redact(e); - throw e; + throw; } catch (std::exception& e) { log() << "mr failed, removing collection" << causedBy(e); - throw e; + throw; } catch (...) { log() << "mr failed for unknown reason, removing collection"; throw; diff --git a/src/mongo/db/concurrency/write_conflict_exception.h b/src/mongo/db/concurrency/write_conflict_exception.h index 3a6c7074a04..7b7e1cc1e9a 100644 --- a/src/mongo/db/concurrency/write_conflict_exception.h +++ b/src/mongo/db/concurrency/write_conflict_exception.h @@ -43,7 +43,7 @@ namespace mongo { * For example if two operations get the same version of a document, and then both try to * modify that document, this exception will get thrown by one of them. */ -class WriteConflictException : public DBException { +class WriteConflictException final : public DBException { public: WriteConflictException(); @@ -60,6 +60,9 @@ public: * Can be set via setParameter named traceWriteConflictExceptions. */ static AtomicBool trace; + +private: + void defineOnlyInFinalSubclassToPreventSlicing() final {} }; /** diff --git a/src/mongo/db/keys_collection_manager_sharding.cpp b/src/mongo/db/keys_collection_manager_sharding.cpp index 13bac7a5359..10c983d661b 100644 --- a/src/mongo/db/keys_collection_manager_sharding.cpp +++ b/src/mongo/db/keys_collection_manager_sharding.cpp @@ -190,8 +190,8 @@ void KeysCollectionManagerSharding::PeriodicRunner::refreshNow(OperationContext* stdx::lock_guard<stdx::mutex> lk(_mutex); if (_inShutdown) { - throw DBException(ErrorCodes::ShutdownInProgress, - "aborting keys cache refresh because node is shutting down"); + uasserted(ErrorCodes::ShutdownInProgress, + "aborting keys cache refresh because node is shutting down"); } if (_refreshRequest) { @@ -207,7 +207,7 @@ void KeysCollectionManagerSharding::PeriodicRunner::refreshNow(OperationContext* // waitFor also throws if timeout, so also throw when notification was not satisfied after // waiting. if (!refreshRequest->waitFor(opCtx, kDefaultRefreshWaitTime)) { - throw DBException(ErrorCodes::ExceededTimeLimit, "timed out waiting for refresh"); + uasserted(ErrorCodes::ExceededTimeLimit, "timed out waiting for refresh"); } } diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index 4cf25eafbad..27e53a898c9 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -509,12 +509,13 @@ WriteResult performInserts(OperationContext* opCtx, const write_ops::Insert& who if (canContinue && !fixedDoc.isOK()) { globalOpCounters.gotInsert(); - canContinue = handleError( - opCtx, - AssertionException(fixedDoc.getStatus().code(), fixedDoc.getStatus().reason()), - wholeOp.getNamespace(), - wholeOp.getWriteCommandBase(), - &out); + try { + uassertStatusOK(fixedDoc.getStatus()); + MONGO_UNREACHABLE; + } catch (const DBException& ex) { + canContinue = handleError( + opCtx, ex, wholeOp.getNamespace(), wholeOp.getWriteCommandBase(), &out); + } } if (!canContinue) diff --git a/src/mongo/db/pipeline/close_change_stream_exception.h b/src/mongo/db/pipeline/close_change_stream_exception.h index 782255e2f92..b3216d9c8a4 100644 --- a/src/mongo/db/pipeline/close_change_stream_exception.h +++ b/src/mongo/db/pipeline/close_change_stream_exception.h @@ -37,10 +37,13 @@ namespace mongo { * An exception used to signal to the aggregate and getMore commands that a change stream has been * invalidated, and the cursor should not be left open. */ -class CloseChangeStreamException : public DBException { +class CloseChangeStreamException final : public DBException { public: CloseChangeStreamException() : DBException(ErrorCodes::CloseChangeStream, "CloseChangeStream") {} + +private: + void defineOnlyInFinalSubclassToPreventSlicing() final {} }; } // namespace mongo diff --git a/src/mongo/db/repl/apply_ops.cpp b/src/mongo/db/repl/apply_ops.cpp index f6651330cbe..68fa9eba81a 100644 --- a/src/mongo/db/repl/apply_ops.cpp +++ b/src/mongo/db/repl/apply_ops.cpp @@ -165,10 +165,9 @@ Status _applyOps(OperationContext* opCtx, if (!db) { // Retry in non-atomic mode, since MMAP cannot implicitly create a new database // within an active WriteUnitOfWork. - throw DBException( - ErrorCodes::AtomicityFailure, - "cannot create a database in atomic applyOps mode; will retry without " - "atomicity"); + uasserted(ErrorCodes::AtomicityFailure, + "cannot create a database in atomic applyOps mode; will retry without " + "atomicity"); } // When processing an update on a non-existent collection, applyOperation_inlock() @@ -178,7 +177,7 @@ Status _applyOps(OperationContext* opCtx, // Additionally for inserts, we fail early on non-existent collections. auto collection = db->getCollection(opCtx, nss); if (!collection && !nss.isSystemDotIndexes() && (*opType == 'i' || *opType == 'u')) { - throw DBException( + uasserted( ErrorCodes::AtomicityFailure, str::stream() << "cannot apply insert or update operation on a non-existent namespace " @@ -189,9 +188,9 @@ Status _applyOps(OperationContext* opCtx, // Cannot specify timestamp values in an atomic applyOps. if (opObj.hasField("ts")) { - throw DBException(ErrorCodes::AtomicityFailure, - "cannot apply an op with a timestamp in atomic applyOps mode; " - "will retry without atomicity"); + uasserted(ErrorCodes::AtomicityFailure, + "cannot apply an op with a timestamp in atomic applyOps mode; " + "will retry without atomicity"); } OldClientContext ctx(opCtx, nss.ns()); @@ -218,13 +217,13 @@ Status _applyOps(OperationContext* opCtx, if (*opType == 'd') { return Status::OK(); } - throw DBException(ErrorCodes::NamespaceNotFound, - str::stream() - << "cannot apply insert or update operation on a " - "non-existent namespace " - << nss.ns() - << ": " - << mongo::redact(opObj)); + uasserted(ErrorCodes::NamespaceNotFound, + str::stream() + << "cannot apply insert or update operation on a " + "non-existent namespace " + << nss.ns() + << ": " + << mongo::redact(opObj)); } OldClientContext ctx(opCtx, nss.ns()); diff --git a/src/mongo/db/repl/master_slave.h b/src/mongo/db/repl/master_slave.h index e404a3fb0ec..cc7f9cce13a 100644 --- a/src/mongo/db/repl/master_slave.h +++ b/src/mongo/db/repl/master_slave.h @@ -59,9 +59,12 @@ extern AtomicInt32 syncing; extern const char* replInfo; /* A replication exception */ -class SyncException : public DBException { +class SyncException final : public DBException { public: SyncException() : DBException(10001, "sync exception") {} + +private: + void defineOnlyInFinalSubclassToPreventSlicing() final {} }; /* A Source is a source from which we can pull (replicate) data. diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index e91fa140176..5c023bd022c 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -588,7 +588,7 @@ void createOplog(OperationContext* opCtx, const std::string& oplogCollectionName ss << "cmdline oplogsize (" << n << ") different than existing (" << o << ") see: http://dochub.mongodb.org/core/increase-oplog"; log() << ss.str() << endl; - throw AssertionException(13257, ss.str()); + uasserted(13257, ss.str()); } } acquireOplogCollectionForLogging(opCtx); @@ -1394,8 +1394,7 @@ Status applyOperation_inlock(OperationContext* opCtx, } } else { invariant(*opType != 'c'); // commands are processed in applyCommand_inlock() - throw AssertionException( - 14825, str::stream() << "error in applyOperation : unknown opType " << *opType); + uasserted(14825, str::stream() << "error in applyOperation : unknown opType " << *opType); } return Status::OK(); diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 0c1fc3ebb4c..d74bc54437c 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -1331,7 +1331,7 @@ void rollback_internal::syncFixUp(OperationContext* opCtx, wunit.commit(); }); } else { - throw e; + throw; } } } diff --git a/src/mongo/db/repl/rs_rollback_no_uuid.cpp b/src/mongo/db/repl/rs_rollback_no_uuid.cpp index 5c56c4f3101..b1a633abf7e 100644 --- a/src/mongo/db/repl/rs_rollback_no_uuid.cpp +++ b/src/mongo/db/repl/rs_rollback_no_uuid.cpp @@ -789,7 +789,7 @@ void syncFixUp(OperationContext* opCtx, wunit.commit(); }); } else { - throw e; + throw; } } } diff --git a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp index 78bda18e878..df75d2ba8aa 100644 --- a/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp +++ b/src/mongo/db/storage/mmap_v1/catalog/namespace_details.cpp @@ -125,7 +125,7 @@ IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) { Extra* e = extra(); if (!e) { if (missingExpected) - throw AssertionException(13283, "Missing Extra"); + uasserted(13283, "Missing Extra"); massert(14045, "missing Extra", e); } int i = idxNo - NIndexesBase; @@ -133,7 +133,7 @@ IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) { e = e->next(this); if (!e) { if (missingExpected) - throw AssertionException(14823, "missing extra"); + uasserted(14823, "missing extra"); massert(14824, "missing Extra", e); } i -= NIndexesExtra; @@ -150,7 +150,7 @@ const IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) const const Extra* e = extra(); if (!e) { if (missingExpected) - throw AssertionException(17421, "Missing Extra"); + uasserted(17421, "Missing Extra"); massert(17422, "missing Extra", e); } int i = idxNo - NIndexesBase; @@ -158,7 +158,7 @@ const IndexDetails& NamespaceDetails::idx(int idxNo, bool missingExpected) const e = e->next(this); if (!e) { if (missingExpected) - throw AssertionException(17423, "missing extra"); + uasserted(17423, "missing extra"); massert(17424, "missing Extra", e); } i -= NIndexesExtra; diff --git a/src/mongo/db/storage/mmap_v1/dur_journal.cpp b/src/mongo/db/storage/mmap_v1/dur_journal.cpp index 364948e3226..bfb39a0bc6c 100644 --- a/src/mongo/db/storage/mmap_v1/dur_journal.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_journal.cpp @@ -417,7 +417,7 @@ void checkFreeSpace() { log() << "Please make at least " << spaceNeeded / (1024 * 1024) << "MB available in " << getJournalDir().string() << " or use --smallfiles" << endl; log() << endl; - throw AssertionException(15926, "Insufficient free space for journals"); + uasserted(15926, "Insufficient free space for journals"); } } |