0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
This commit is contained in:
Dwight 2010-04-22 18:43:37 -04:00
parent 0976928780
commit ca84dc6bb1
9 changed files with 62 additions and 24 deletions

View File

@ -299,7 +299,7 @@ namespace mongo {
} cmdCursorInfo;
void ClientCursorMonitor::run(){
Client::initThread("snapshotthread");
Client::initThread("clientcursormon");
Client& client = cc();
unsigned old = curTimeMillis();

View File

@ -114,15 +114,17 @@ namespace mongo {
ss << "\n<b>dbtop</b> (occurences|percent of elapsed)\n";
ss << "<table border=1 cellpadding=2 cellspacing=0>";
ss << "<tr align='left'>";
ss << "<th><a title=\"namespace\">NS</a></th>"
"<th colspan=2>total</th>"
"<th colspan=2>Reads</th>"
"<th colspan=2>Writes</th>"
"<th colspan=2>Queries</th>"
"<th colspan=2>GetMores</th>"
"<th colspan=2>Inserts</th>"
"<th colspan=2>Updates</th>"
"<th colspan=2>Removes</th>";
ss << "<th><a title=\"namespace\" href=\""
"http://www.mongodb.org/display/DOCS/Developer+FAQ#DeveloperFAQ-What%27sa%22namespace%22%3F"
"\">NS</a></th>"
"<th colspan=2>total</th>"
"<th colspan=2>Reads</th>"
"<th colspan=2>Writes</th>"
"<th colspan=2>Queries</th>"
"<th colspan=2>GetMores</th>"
"<th colspan=2>Inserts</th>"
"<th colspan=2>Updates</th>"
"<th colspan=2>Removes</th>";
ss << "</tr>";
display( ss , (double) delta->elapsed() , "GLOBAL" , delta->globalUsageDiff() );
@ -184,7 +186,9 @@ namespace mongo {
ss << "git hash: " << gitVersion() << '\n';
ss << "sys info: " << sysInfo() << '\n';
ss << '\n';
ss << "<a title=\"snapshot: was the db in the write lock when this page was generated?\">";
ss << "<a "
<< "href=\"http://www.mongodb.org/pages/viewpage.action?pageId=7209296\""
<< "title=\"snapshot: was the db in the write lock when this page was generated?\">";
ss << "write locked:</a> " << (dbMutex.info().isLocked() ? "true" : "false") << "\n";
ss << "uptime: " << time(0)-started << " seconds\n";
if ( replAllDead )
@ -194,7 +198,10 @@ namespace mongo {
ss << "assertions:</a>\n";
for ( int i = 0; i < 4; i++ ) {
if ( lastAssert[i].isSet() ) {
if ( i == 3 ) ss << "usererr";
if ( i == 3 ) ss << "uassert";
else if( i == 2 ) ss << "massert";
else if( i == 0 ) ss << "assert";
else if( i == 1 ) ss << "warnassert";
else ss << i;
ss << ' ' << lastAssert[i].toString();
}
@ -415,7 +422,9 @@ namespace mongo {
}
}
ss << '\n';
ss << "rest/admin port:" << _port << "\n";
ss << "<a "
"title=\"click for documentation on this http interface\""
"href=\"http://www.mongodb.org/display/DOCS/Http+Interface\">HTTP</a> admin port:" << _port << "\n";
doUnlockedStuff(ss);
{

View File

@ -344,7 +344,7 @@ namespace mongo {
return true;
}
virtual LockType locktype(){ return NONE; }
CmdIsMasterOld(const char * name="ismaster") : Command(name, true) { }
CmdIsMasterOld(const char * name="ismaster") : Command(name, name=="isMaster") { }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool /*fromRepl*/) {
/* currently request to arbiter is (somewhat arbitrarily) an ismaster request that is not
authenticated.
@ -357,6 +357,7 @@ namespace mongo {
result.append("ismaster", 0);
result.append("ok", false);
result.append("msg", "replSet still trying to initialize");
result.append("info", ReplSet::startupStatusMsg);
return true;
}
theReplSet->fillIsMaster(result);

View File

@ -37,6 +37,7 @@ namespace mongo {
errmsg = "not a replset member";
return false;
}
result.append("rs", true);
if( theReplSet == 0 ) {
errmsg = "still initializing";
return false;

View File

@ -103,7 +103,7 @@ namespace mongo {
startupStatus = EMPTYCONFIG;
startupStatusMsg = "can't get admin.system.replset config from self or any seed (uninitialized?)";
log() << "replSet can't get admin.system.replset config from self or any seed.\n";
log() << "replSet have you ran commant replSetInitiate yet?\n";
log() << "replSet have you ran replSetInitiate yet?\n";
log() << "replSet sleeping 1 minute and will try again." << endl;
}
else {
@ -118,8 +118,8 @@ namespace mongo {
}
catch(AssertionException&) {
startupStatus = BADCONFIG;
startupStatusMsg = "replSet bad config";
log() << "replSet error loading configurations. admin.system.replset may be misconfigured\n";
startupStatusMsg = "replSet error loading set config";
log() << "replSet error loading configurations\n";
log() << "replSet replication will not start" << endl;
fatal = true;
throw;

View File

@ -31,7 +31,7 @@ namespace mongo {
CmdReplSetInitiate() : Command("replSetInitiate") { }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
if( !replSet ) {
errmsg = "not running with --replSet";
errmsg = "server is not running with --replSet";
return false;
}
if( theReplSet ) {
@ -39,7 +39,8 @@ namespace mongo {
return false;
}
if( ReplSet::startupStatus == ReplSet::BADCONFIG ) {
errmsg = "config already exists, but is bad";
errmsg = "server already in BADCONFIG state (check logs); not initiating";
result.append("info", ReplSet::startupStatusMsg);
return false;
}
if( ReplSet::startupStatus != ReplSet::EMPTYCONFIG ) {
@ -54,7 +55,7 @@ namespace mongo {
/* commands in other files:
replSetHeartbeat - health.cpp
*/
*/
class CmdReplSetGetStatus : public Command {
public:

View File

@ -18,6 +18,7 @@
#include "stdafx.h"
#include "rs_config.h"
#include "replset.h"
#include "../../client/dbclient.h"
#include "../../util/hostandport.h"
@ -66,7 +67,8 @@ namespace mongo {
uassert(13122, "bad local.system.replset config", expr);
}
ReplSetConfig::ReplSetConfig(const HostAndPort& h) : version(-4) {
ReplSetConfig::ReplSetConfig(const HostAndPort& h) {
version = -5;
int level = 2;
DEV level = 0;
_ok = false;
@ -78,10 +80,26 @@ namespace mongo {
conn._logLevel = 2;
string err;
conn.connect(h.toString());
version = -4;
{
/* first, make sure other node is configured to be a replset. just to be safe. */
BSONObj cmd = BSON( "replSetHeartbeat" << "preloadconfig?" );
BSONObj info;
bool ok = conn.runCommand("admin", cmd, info);
cout << h.toString() << " " << ok << " " << info.toString() << endl;
if( !info["rs"].trueValue() ) {
stringstream ss;
ss << "replSet error: member " << h.toString() << " is not in --replSet mode";
msgassertedNoTrace(10000, ss.str().c_str()); // not caught as not a user exception - we want it not caught
}
}
version = -3;
c = conn.query("local.system.replset");
if( !c->more() ) {
version = -2;
version = -2; /* -2 is a sentinel - see ReplSetConfig::empty() */
return;
}
version = -1;

View File

@ -92,7 +92,15 @@ namespace mongo {
lastAssert[2].set(msg, getDbContext().c_str(), "", 0);
raiseError(msgid,msg && *msg ? msg : "massert failure");
breakpoint();
printStackTrace(); // TEMP?? should we get rid of this? TODO
printStackTrace();
throw MsgAssertionException(msgid, msg);
}
void msgassertedNoTrace(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");
throw MsgAssertionException(msgid, msg);
}

View File

@ -150,6 +150,7 @@ namespace mongo {
void uasserted(int msgid, const char *msg);
inline void uasserted(int msgid , string msg) { uasserted(msgid, msg.c_str()); }
void uassert_nothrow(const char *msg); // reported via lasterror, but don't throw exception
void msgassertedNoTrace(int msgid, const char *msg);
void msgasserted(int msgid, const char *msg);
inline void msgasserted(int msgid, string msg) { msgasserted(msgid, msg.c_str()); }
@ -160,7 +161,6 @@ namespace mongo {
#define assert(_Expression) (void)( (!!(_Expression)) || (mongo::asserted(#_Expression, __FILE__, __LINE__), 0) )
/* "user assert". if asserts, user did something wrong, not our code */
//#define uassert( 10269 , _Expression) (void)( (!!(_Expression)) || (uasserted(#_Expression, __FILE__, __LINE__), 0) )
#define uassert(msgid, msg,_Expression) (void)( (!!(_Expression)) || (mongo::uasserted(msgid, msg), 0) )
#define xassert(_Expression) (void)( (!!(_Expression)) || (mongo::asserted(#_Expression, __FILE__, __LINE__), 0) )