diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 17f668441f4..f91508b3b2e 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -166,6 +166,21 @@ string validateNS(const char *ns, NamespaceDetails *d) { return ss.str(); } +/* just to check if the db has asserted */ +class CmdAsserts : public Command { +public: + CmdAsserts() : Command("assertinfo") {} + bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) { + result.appendBool("dbasserted", lastAssert[0].isSet() || lastAssert[1].isSet() || lastAssert[2].isSet()); + result.appendBool("asserted", lastAssert[0].isSet() || lastAssert[1].isSet() || lastAssert[2].isSet() || lastAssert[3].isSet()); + result.append("assert", lastAssert[AssertRegular].toString()); + result.append("assertw", lastAssert[AssertW].toString()); + result.append("assertmsg", lastAssert[AssertMsg].toString()); + result.append("assertuser", lastAssert[AssertUser].toString()); + return true; + } +} cmdAsserts; + class CmdGetOpTime : public Command { public: CmdGetOpTime() : Command("getoptime") { } diff --git a/stdafx.cpp b/stdafx.cpp index b080b7c6b49..f02f44d5e1e 100644 --- a/stdafx.cpp +++ b/stdafx.cpp @@ -60,6 +60,9 @@ void msgasserted(const char *msg) { } string Assertion::toString() { + if( !isSet() ) + return ""; + stringstream ss; ss << msg << '\n'; if( *context ) diff --git a/stdafx.h b/stdafx.h index 1f4da3d37b0..56502b7c3f8 100644 --- a/stdafx.h +++ b/stdafx.h @@ -80,7 +80,14 @@ struct Assertion { bool isSet() { return when != 0; } }; -/* last assert of diff types: regular, assert, msgassert, uassert: */ +enum { + AssertRegular = 0, + AssertW = 1, + AssertMsg = 2, + AssertUser = 3 +}; + +/* last assert of diff types: regular, wassert, msgassert, uassert: */ extern Assertion lastAssert[4]; // you can catch these