0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

$cmd assertinfo

This commit is contained in:
Dwight 2008-12-05 11:06:51 -05:00
parent 1a95c75d0f
commit 4b161903e4
3 changed files with 26 additions and 1 deletions

View File

@ -166,6 +166,21 @@ string validateNS(const char *ns, NamespaceDetails *d) {
return ss.str(); 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 { class CmdGetOpTime : public Command {
public: public:
CmdGetOpTime() : Command("getoptime") { } CmdGetOpTime() : Command("getoptime") { }

View File

@ -60,6 +60,9 @@ void msgasserted(const char *msg) {
} }
string Assertion::toString() { string Assertion::toString() {
if( !isSet() )
return "";
stringstream ss; stringstream ss;
ss << msg << '\n'; ss << msg << '\n';
if( *context ) if( *context )

View File

@ -80,7 +80,14 @@ struct Assertion {
bool isSet() { return when != 0; } 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]; extern Assertion lastAssert[4];
// you can catch these // you can catch these