mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
$cmd assertinfo
This commit is contained in:
parent
1a95c75d0f
commit
4b161903e4
@ -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") { }
|
||||||
|
@ -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 )
|
||||||
|
9
stdafx.h
9
stdafx.h
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user