diff options
-rw-r--r-- | src/mongo/client/dbclient.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/commands/mr.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_info.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp | 17 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/dur_commitjob.h | 1 | ||||
-rw-r--r-- | src/mongo/shell/bench.cpp | 5 | ||||
-rw-r--r-- | src/mongo/util/assert_util.cpp | 25 | ||||
-rw-r--r-- | src/mongo/util/assert_util.h | 10 | ||||
-rw-r--r-- | src/mongo/util/checksum.h | 1 |
9 files changed, 18 insertions, 68 deletions
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp index 0f82f291d21..93b3f384c04 100644 --- a/src/mongo/client/dbclient.cpp +++ b/src/mongo/client/dbclient.cpp @@ -1443,21 +1443,7 @@ bool DBClientConnection::call(Message& toSend, } BSONElement getErrField(const BSONObj& o) { - BSONElement first = o.firstElement(); - if (strcmp(first.fieldName(), "$err") == 0) - return first; - - // temp - will be DEV only later - /*DEV*/ - if (1) { - BSONElement e = o["$err"]; - if (!e.eoo()) { - wassert(false); - } - return e; - } - - return BSONElement(); + return o["$err"]; } bool hasErrField(const BSONObj& o) { diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp index 9764944a5dd..35b0aaca426 100644 --- a/src/mongo/db/commands/mr.cpp +++ b/src/mongo/db/commands/mr.cpp @@ -1433,13 +1433,15 @@ public: state.prepTempCollection(); ON_BLOCK_EXIT_OBJ(state, &State::dropTempCollections); - int progressTotal = 0; + int64_t progressTotal = 0; bool showTotal = true; if (state.config().filter.isEmpty()) { const bool holdingGlobalLock = false; const auto count = _collectionCount(opCtx, config.nss, holdingGlobalLock); progressTotal = - (config.limit && (unsigned)config.limit < count) ? config.limit : count; + (config.limit && static_cast<unsigned long long>(config.limit) < count) + ? config.limit + : count; } else { showTotal = false; // Set an arbitrary total > 0 so the meter will be activated. @@ -1453,9 +1455,6 @@ public: progress.showTotal(showTotal); ProgressMeterHolder pm(progress); - // See cast on next line to 32 bit unsigned - wassert(config.limit < 0x4000000); - long long mapTime = 0; long long reduceTime = 0; long long numInputs = 0; diff --git a/src/mongo/db/repl/replication_info.cpp b/src/mongo/db/repl/replication_info.cpp index ebcbb8034ab..2a772d192dd 100644 --- a/src/mongo/db/repl/replication_info.cpp +++ b/src/mongo/db/repl/replication_info.cpp @@ -126,7 +126,7 @@ void appendReplicationInfo(OperationContext* opCtx, BSONObjBuilder& result, int } if (level > 1) { - wassert(!opCtx->lockState()->isLocked()); + invariant(!opCtx->lockState()->isLocked()); // note: there is no so-style timeout on this connection; perhaps we should have // one. ScopedDbConnection conn(s["host"].valuestr()); diff --git a/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp b/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp index 3c793c1534a..4e77412b24a 100644 --- a/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp +++ b/src/mongo/db/storage/mmap_v1/btree/btree_logic.cpp @@ -1105,7 +1105,7 @@ Status BtreeLogic<BtreeLayout>::_find(OperationContext* opCtx, // Some debugging checks. if (low != bucket->n) { - wassert(key.woCompare(getFullKey(bucket, low).data, _ordering) <= 0); + invariant(key.woCompare(getFullKey(bucket, low).data, _ordering) <= 0); if (low > 0) { if (getFullKey(bucket, low - 1).data.woCompare(key, _ordering) > 0) { @@ -1113,7 +1113,7 @@ Status BtreeLogic<BtreeLayout>::_find(OperationContext* opCtx, log() << key.toString() << endl; log() << getFullKey(bucket, low - 1).data.toString() << endl; } - wassert(false); + invariant(false); } } } @@ -2061,8 +2061,8 @@ long long BtreeLogic<BtreeLayout>::_fullValidate(OperationContext* opCtx, if (strict) { invariant(b->parent == bucketLoc); - } else { - wassert(b->parent == bucketLoc); + } else if (b->parent != bucketLoc) { + warning() << "index corruption detected: b->parent != bucketLoc"; } keyCount += _fullValidate(opCtx, left, unusedCount, strict, dumpBuckets, depth + 1); @@ -2073,8 +2073,8 @@ long long BtreeLogic<BtreeLayout>::_fullValidate(OperationContext* opCtx, BucketType* b = getBucket(opCtx, bucket->nextChild); if (strict) { invariant(b->parent == bucketLoc); - } else { - wassert(b->parent == bucketLoc); + } else if (b->parent != bucketLoc) { + warning() << "index corruption detected: b->parent != bucketLoc"; } keyCount += @@ -2119,7 +2119,7 @@ void BtreeLogic<BtreeLayout>::assertValid(const std::string& ns, } dumpBucket(bucket); } - wassert(false); + invariant(false); break; } else if (z == 0) { if (!(firstKey.header.recordLoc < secondKey.header.recordLoc)) { @@ -2128,7 +2128,7 @@ void BtreeLogic<BtreeLayout>::assertValid(const std::string& ns, << " RL:" << firstKey.header.recordLoc.toString() << endl; log() << " k(" << i + 1 << ")" << redact(secondKey.data.toString()) << " RL:" << secondKey.header.recordLoc.toString() << endl; - wassert(firstKey.header.recordLoc < secondKey.header.recordLoc); + invariant(firstKey.header.recordLoc < secondKey.header.recordLoc); } } } @@ -2139,7 +2139,6 @@ void BtreeLogic<BtreeLayout>::assertValid(const std::string& ns, FullKey k1 = getFullKey(bucket, 0); FullKey k2 = getFullKey(bucket, bucket->n - 1); int z = k1.data.woCompare(k2.data, ordering); - // wassert( z <= 0 ); if (z > 0) { log() << "Btree keys out of order in collection " << ns; std::call_once(assertValidFlag, [&bucket]() { dumpBucket(bucket); }); diff --git a/src/mongo/db/storage/mmap_v1/dur_commitjob.h b/src/mongo/db/storage/mmap_v1/dur_commitjob.h index 8261b613c57..80d6cf900f5 100644 --- a/src/mongo/db/storage/mmap_v1/dur_commitjob.h +++ b/src/mongo/db/storage/mmap_v1/dur_commitjob.h @@ -197,7 +197,6 @@ public: private: void _insertWriteIntent(void* p, int len) { _intents.push_back(WriteIntent(p, len)); - wassert(_intents.size() < 2000000); } diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp index 5c9472c39c1..9bede407b3a 100644 --- a/src/mongo/shell/bench.cpp +++ b/src/mongo/shell/bench.cpp @@ -633,7 +633,10 @@ BenchRunState::BenchRunState(unsigned numWorkers) _isCollectingStats(0) {} BenchRunState::~BenchRunState() { - wassert(_numActiveWorkers == 0 && _numUnstartedWorkers == 0); + if (_numActiveWorkers != 0) + warning() << "Destroying BenchRunState with active workers"; + if (_numUnstartedWorkers != 0) + warning() << "Destroying BenchRunState with unstarted workers"; } void BenchRunState::waitForState(State awaitedState) { diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp index 1049b359b81..7fda800f414 100644 --- a/src/mongo/util/assert_util.cpp +++ b/src/mongo/util/assert_util.cpp @@ -82,31 +82,6 @@ void DBException::traceIfNeeded(const DBException& e) { } } -/* "warning" assert -- safe to continue, so we don't throw exception. */ -NOINLINE_DECL void wasserted(const char* expr, const char* file, unsigned line) { - static bool rateLimited; - static time_t lastWhen; - static unsigned lastLine; - if (lastLine == line && time(0) - lastWhen < 5) { - if (!rateLimited) { - rateLimited = true; - log() << "rate limiting wassert" << endl; - } - return; - } - lastWhen = time(0); - lastLine = line; - - warning() << "warning assertion failure " << expr << ' ' << file << ' ' << dec << line << endl; - logContext(); - assertionCount.condrollover(++assertionCount.warning); -#if defined(MONGO_CONFIG_DEBUG_BUILD) - // this is so we notice in buildbot - severe() << "\n\n***aborting after wassert() failure in a debug/test build\n\n" << endl; - std::abort(); -#endif -} - NOINLINE_DECL void verifyFailed(const char* expr, const char* file, unsigned line) { assertionCount.condrollover(++assertionCount.regular); error() << "Assertion failure " << expr << ' ' << file << ' ' << dec << line << endl; diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index 1ed24cec710..ae00f8e4053 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -220,7 +220,6 @@ MONGO_COMPILER_NORETURN void invariantOKFailed(const char* expr, const Status& status, const char* file, unsigned line) noexcept; -void wasserted(const char* expr, const char* file, unsigned line); #define fassertFailed MONGO_fassertFailed #define MONGO_fassertFailed(...) ::mongo::fassertFailedWithLocation(__VA_ARGS__, __FILE__, __LINE__) @@ -435,15 +434,6 @@ inline void fassertStatusOKWithLocation(int msgid, } } -/* warning only - keeps going */ -#define wassert MONGO_wassert -#define MONGO_wassert(_Expression) \ - do { \ - if (MONGO_unlikely(!(_Expression))) { \ - ::mongo::wasserted(#_Expression, __FILE__, __LINE__); \ - } \ - } while (false) - /** * verify is deprecated. It is like invariant() in debug builds and massert() in release builds. */ diff --git a/src/mongo/util/checksum.h b/src/mongo/util/checksum.h index 7b04b38bdc1..c118a054f4c 100644 --- a/src/mongo/util/checksum.h +++ b/src/mongo/util/checksum.h @@ -41,7 +41,6 @@ struct Checksum { // if you change this you must bump dur::CurrentVersion void gen(const void* buf, unsigned len) { - wassert(((size_t)buf) % 8 == 0); // performance warning unsigned n = len / 8 / 2; ConstDataCursor cdc(static_cast<const char*>(buf)); uint64_t a = 0; |