summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2012-11-20 10:19:24 -0500
committerGreg Studer <greg@10gen.com>2012-11-20 12:04:36 -0500
commit37e3c78fd0fd25be18fbfe650a70d0a7d90fcd60 (patch)
tree3395fa65a5311e91890661a2302d6807830f4a17
parent7aac243b122f4ac073f81a1f98182d40bc322ffc (diff)
downloadmongo-37e3c78fd0fd25be18fbfe650a70d0a7d90fcd60.tar.gz
SERVER-7666 make connPoolStats always report the state of all replica sets being tracked
-rw-r--r--jstests/replsets/stale_clustered.js20
-rw-r--r--src/mongo/client/connpool.cpp10
-rw-r--r--src/mongo/client/dbclient_rs.cpp9
-rw-r--r--src/mongo/client/dbclient_rs.h4
4 files changed, 15 insertions, 28 deletions
diff --git a/jstests/replsets/stale_clustered.js b/jstests/replsets/stale_clustered.js
index 633387e282f..ecb3532d4b3 100644
--- a/jstests/replsets/stale_clustered.js
+++ b/jstests/replsets/stale_clustered.js
@@ -38,26 +38,6 @@ rsB.getMaster().getDB( "test_b" ).dummy.insert( { x : 1 } )
rsA.awaitReplication()
rsB.awaitReplication()
-// TEMPORARY
-
-// SERVER-7699
-
-// We need to do something with with both shards using a non-ShardConnection in order for our
-// connPoolStats to report our replica set status, so we just movePrimary some database back
-// and forth using the conn of collSOk
-
-prt("0: fix bug")
-
-var shards = collSOk.getMongo().getDB("config").shards.find().toArray();
-
-assert.eq(null, collSOk.getMongo().getDB("touchBothShards").coll.findOne());
-printjson(collSOk.getMongo().getDB("admin").runCommand({ movePrimary : "touchBothShards", to : shards[1]._id }))
-printjson(collSOk.getMongo().getDB("admin").runCommand({ movePrimary : "touchBothShards", to : shards[0]._id }))
-jsTest.log("Conn pool stats:")
-printjson(collSOk.getMongo().getDB( "admin" ).runCommand( "connPoolStats" ));
-
-// END TEMPORARY
-
prt("1: initial insert")
coll.save({ _id : -1, a : "a", date : new Date() })
diff --git a/src/mongo/client/connpool.cpp b/src/mongo/client/connpool.cpp
index ed2d607f29e..81a0579ed7d 100644
--- a/src/mongo/client/connpool.cpp
+++ b/src/mongo/client/connpool.cpp
@@ -350,18 +350,12 @@ namespace mongo {
long long& x = createdByType[i->second.type()];
x += i->second.numCreated();
-
- {
- string setName = i->first.ident;
- if ( setName.find( "/" ) != string::npos ) {
- setName = setName.substr( 0 , setName.find( "/" ) );
- replicaSets.insert( setName );
- }
- }
}
}
bb.done();
+ // Always report all replica sets being tracked
+ ReplicaSetMonitor::getAllTrackedSets(&replicaSets);
BSONObjBuilder setBuilder( b.subobjStart( "replicaSets" ) );
for ( set<string>::iterator i=replicaSets.begin(); i!=replicaSets.end(); ++i ) {
diff --git a/src/mongo/client/dbclient_rs.cpp b/src/mongo/client/dbclient_rs.cpp
index d4843f9d88f..18e87f9d2f0 100644
--- a/src/mongo/client/dbclient_rs.cpp
+++ b/src/mongo/client/dbclient_rs.cpp
@@ -388,6 +388,15 @@ namespace mongo {
return ReplicaSetMonitorPtr();
}
+ void ReplicaSetMonitor::getAllTrackedSets(set<string>* activeSets) {
+ scoped_lock lk( _setsLock );
+ for (map<string,ReplicaSetMonitorPtr>::const_iterator it = _sets.begin();
+ it != _sets.end(); ++it)
+ {
+ activeSets->insert(it->first);
+ }
+ }
+
void ReplicaSetMonitor::checkAll( bool checkAllSecondaries ) {
set<string> seen;
diff --git a/src/mongo/client/dbclient_rs.h b/src/mongo/client/dbclient_rs.h
index 4526c24996e..61a0e824800 100644
--- a/src/mongo/client/dbclient_rs.h
+++ b/src/mongo/client/dbclient_rs.h
@@ -190,6 +190,10 @@ namespace mongo {
*/
static ReplicaSetMonitorPtr get( const string& name, const bool createFromSeed = false );
+ /**
+ * Populates activeSets with all the currently tracked replica set names.
+ */
+ static void getAllTrackedSets(set<string>* activeSets);
/**
* checks all sets for current master and new secondaries