diff options
author | Dwight <dwight@10gen.com> | 2010-08-02 14:37:10 -0400 |
---|---|---|
committer | Dwight <dwight@10gen.com> | 2010-08-02 14:37:10 -0400 |
commit | c43462c6b06a49a4319f2483829b34979e09334a (patch) | |
tree | 6f0f398285cca7dc11b8cddcd98069e7e3556723 | |
parent | d949b32d3ca9f492d486a9dc1b42752a987b690a (diff) | |
download | mongo-c43462c6b06a49a4319f2483829b34979e09334a.tar.gz |
lock testing and such
-rw-r--r-- | db/client.cpp | 8 | ||||
-rw-r--r-- | db/dbcommands_generic.cpp | 16 | ||||
-rw-r--r-- | db/repl/health.cpp | 10 | ||||
-rw-r--r-- | db/repl/manager.cpp | 2 |
4 files changed, 29 insertions, 7 deletions
diff --git a/db/client.cpp b/db/client.cpp index af83653c5f2..65c467a2dc0 100644 --- a/db/client.cpp +++ b/db/client.cpp @@ -387,7 +387,13 @@ namespace mongo { tablecell( ss , co.opNum() ); tablecell( ss , co.active() ); - tablecell( ss , co.getLockType() ); + { + int lt = co.getLockType(); + if( lt == -1 ) tablecell(ss, "R"); + else if( lt == 1 ) tablecell(ss, "W"); + else + tablecell( ss , lt); + } tablecell( ss , co.isWaitingForLock() ); if ( co.active() ) tablecell( ss , co.elapsedSeconds() ); diff --git a/db/dbcommands_generic.cpp b/db/dbcommands_generic.cpp index 338dbd0f6ee..2d16c9f232b 100644 --- a/db/dbcommands_generic.cpp +++ b/db/dbcommands_generic.cpp @@ -67,7 +67,7 @@ namespace mongo { /* for diagnostic / testing purposes. */ class CmdSleep : public Command { public: - virtual LockType locktype() const { return READ; } + virtual LockType locktype() const { return NONE; } virtual bool adminOnly() const { return true; } virtual bool logTheOp() { return false; @@ -76,11 +76,19 @@ namespace mongo { return true; } virtual void help( stringstream& help ) const { - help << "internal testing command. Makes db block (in a read lock) for 100 seconds"; + help << "internal testing command. Makes db block (in a read lock) for 100 seconds\n"; + help << "w:true write lock"; } - CmdSleep() : Command("sleep") {} + CmdSleep() : Command("sleep") { } bool run(const string& ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) { - sleepsecs(100); + if( cmdObj.getBoolField("w") ) { + writelock lk(""); + sleepsecs(100); + } + else { + readlock lk(""); + sleepsecs(100); + } return true; } } cmdSleep; diff --git a/db/repl/health.cpp b/db/repl/health.cpp index 1c1cd884751..35da9edcdc6 100644 --- a/db/repl/health.cpp +++ b/db/repl/health.cpp @@ -185,6 +185,10 @@ namespace mongo { ScopedConn conn(m->fullName()); auto_ptr<DBClientCursor> c = conn->query(rsoplog, Query().sort("$natural",1), 20, 0, &fields); + if( c.get() == 0 ) { + ss << "couldn't query " << rsoplog; + return; + } static const char *h[] = {"ts","optime", "h","op","ns","rest",0}; ss << "<style type=\"text/css\" media=\"screen\">" @@ -212,6 +216,10 @@ namespace mongo { } else { auto_ptr<DBClientCursor> c = conn->query(rsoplog, Query().sort("$natural",-1), 20, 0, &fields); + if( c.get() == 0 ) { + ss << "couldn't query [2] " << rsoplog; + return; + } string x; bo o = c->next(); otEnd = o["ts"]._opTime(); @@ -301,7 +309,7 @@ namespace mongo { s << _table(); try { - readlocktry lk("local.replset.minvalid", 1000); + readlocktry lk("local.replset.minvalid", 300); if( lk.got() ) { BSONObj mv; if( Helpers::getSingleton("local.replset.minvalid", mv) ) { diff --git a/db/repl/manager.cpp b/db/repl/manager.cpp index e372ec4a6f8..82a0f01e1ef 100644 --- a/db/repl/manager.cpp +++ b/db/repl/manager.cpp @@ -48,7 +48,7 @@ namespace mongo { task::Server("rs Manager"), rs(_rs), busyWithElectSelf(false), _primary(NOPRIMARY) { } - + Manager::~Manager() { log() << "should never be called?" << rsLog; rs->mgr = 0; |