summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/dbcommands.cpp10
-rw-r--r--util/assert_util.cpp24
-rw-r--r--util/assert_util.h15
3 files changed, 49 insertions, 0 deletions
diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp
index 4ddc9b2cb82..81f351c5184 100644
--- a/db/dbcommands.cpp
+++ b/db/dbcommands.cpp
@@ -380,6 +380,16 @@ namespace mongo {
result.append( "opcounters" , globalOpCounters.getObj() );
+ {
+ BSONObjBuilder asserts( result.subobjStart( "asserts" ) );
+ asserts.append( "regular" , assertionCount.regular );
+ asserts.append( "warning" , assertionCount.warning );
+ asserts.append( "msg" , assertionCount.msg );
+ asserts.append( "user" , assertionCount.user );
+ asserts.append( "rollovers" , assertionCount.rollovers );
+ asserts.done();
+ }
+
if ( ! authed )
result.append( "note" , "run against admin for more info" );
diff --git a/util/assert_util.cpp b/util/assert_util.cpp
index 2783adfe3ac..6bc902e7635 100644
--- a/util/assert_util.cpp
+++ b/util/assert_util.cpp
@@ -22,6 +22,26 @@
namespace mongo {
+ AssertionCount assertionCount;
+
+ AssertionCount::AssertionCount()
+ : regular(0),warning(0),msg(0),user(0),rollovers(0){
+ }
+
+ void AssertionCount::rollover(){
+ rollovers++;
+ regular = 0;
+ warning = 0;
+ msg = 0;
+ user = 0;
+ }
+
+ void AssertionCount::condrollover( int newvalue ){
+ static int max = (int)pow( 2.0 , 30 );
+ if ( newvalue >= max )
+ rollover();
+ }
+
string getDbContext();
Assertion lastAssert[4];
@@ -32,9 +52,11 @@ namespace mongo {
sayDbContext();
raiseError(0,msg && *msg ? msg : "wassertion failure");
lastAssert[1].set(msg, getDbContext().c_str(), file, line);
+ assertionCount.condrollover( ++assertionCount.warning );
}
void asserted(const char *msg, const char *file, unsigned line) {
+ assertionCount.condrollover( ++assertionCount.regular );
problem() << "Assertion failure " << msg << ' ' << file << ' ' << dec << line << endl;
sayDbContext();
raiseError(0,msg && *msg ? msg : "assertion failure");
@@ -54,6 +76,7 @@ namespace mongo {
int uacount = 0;
void uasserted(int msgid, const char *msg) {
+ assertionCount.condrollover( ++assertionCount.user );
if ( ++uacount < 100 )
log() << "User Exception " << msgid << ":" << msg << endl;
else
@@ -64,6 +87,7 @@ namespace mongo {
}
void msgasserted(int msgid, const char *msg) {
+ assertionCount.condrollover( ++assertionCount.warning );
log() << "Assertion: " << msgid << ":" << msg << endl;
lastAssert[2].set(msg, getDbContext().c_str(), "", 0);
raiseError(msgid,msg && *msg ? msg : "massert failure");
diff --git a/util/assert_util.h b/util/assert_util.h
index 506a1a0ea74..81a6b0df20a 100644
--- a/util/assert_util.h
+++ b/util/assert_util.h
@@ -67,6 +67,21 @@ namespace mongo {
/* last assert of diff types: regular, wassert, msgassert, uassert: */
extern Assertion lastAssert[4];
+ class AssertionCount {
+ public:
+ AssertionCount();
+ void rollover();
+ void condrollover( int newValue );
+
+ int regular;
+ int warning;
+ int msg;
+ int user;
+ int rollovers;
+ };
+
+ extern AssertionCount assertionCount;
+
class DBException : public std::exception {
public:
virtual const char* what() const throw() = 0;