summaryrefslogtreecommitdiff
path: root/src/mongo/s/config.cpp
diff options
context:
space:
mode:
authorDaniel Alabi <alabidan@gmail.com>2015-04-23 10:28:47 -0400
committerDaniel Alabi <alabidan@gmail.com>2015-04-29 18:51:45 -0400
commit336085ecb5e457194843d920eae5b0d42ea8b4b0 (patch)
treec2ca1555a2b86f5b295e8bad64fadcc317ab980a /src/mongo/s/config.cpp
parenta0a7b6ff5da4d9768e0650369c8e9fccc2c838c9 (diff)
downloadmongo-336085ecb5e457194843d920eae5b0d42ea8b4b0.tar.gz
SERVER-18125 Move config server consistency checking behind the legacy catalog manager
Diffstat (limited to 'src/mongo/s/config.cpp')
-rw-r--r--src/mongo/s/config.cpp129
1 files changed, 0 insertions, 129 deletions
diff --git a/src/mongo/s/config.cpp b/src/mongo/s/config.cpp
index c5d4742095e..fa72bf41572 100644
--- a/src/mongo/s/config.cpp
+++ b/src/mongo/s/config.cpp
@@ -750,135 +750,6 @@ namespace mongo {
return true;
}
- bool ConfigServer::checkConfigServersConsistent( string& errmsg , int tries ) const {
- if ( tries <= 0 )
- return false;
-
- unsigned firstGood = 0;
- int up = 0;
- vector<BSONObj> res;
- // The last error we saw on a config server
- string error;
- for ( unsigned i=0; i<_config.size(); i++ ) {
- BSONObj result;
-
- scoped_ptr<ScopedDbConnection> conn;
-
- try {
- conn.reset( new ScopedDbConnection( _config[i], 30.0 ) );
-
- if ( ! conn->get()->runCommand( "config",
- BSON( "dbhash" << 1 <<
- "collections" << BSON_ARRAY( "chunks" <<
- "databases" <<
- "collections" <<
- "shards" <<
- "version" )),
- result ) ) {
-
- // TODO: Make this a helper
- error = result["errmsg"].eoo() ? "" : result["errmsg"].String();
- if (!result["assertion"].eoo()) error = result["assertion"].String();
-
- warning() << "couldn't check dbhash on config server " << _config[i]
- << causedBy(result.toString()) << endl;
-
- result = BSONObj();
- }
- else {
- result = result.getOwned();
- if ( up == 0 )
- firstGood = i;
- up++;
- }
- conn->done();
- }
- catch ( const DBException& e ) {
- if (conn) {
- conn->kill();
- }
-
- // We need to catch DBExceptions b/c sometimes we throw them
- // instead of socket exceptions when findN fails
-
- error = e.toString();
- warning() << " couldn't check dbhash on config server " << _config[i] << causedBy(e) << endl;
- }
- res.push_back(result);
- }
-
- if ( _config.size() == 1 )
- return true;
-
- if ( up == 0 ) {
- // Use a ptr to error so if empty we won't add causedby
- errmsg = str::stream() << "no config servers successfully contacted" << causedBy(&error);
- return false;
- }
-
- if ( up == 1 ) {
- warning() << "only 1 config server reachable, continuing" << endl;
- return true;
- }
-
- BSONObj base = res[firstGood];
- for ( unsigned i=firstGood+1; i<res.size(); i++ ) {
- if ( res[i].isEmpty() )
- continue;
-
- string chunksHash1 = base.getFieldDotted( "collections.chunks" );
- string chunksHash2 = res[i].getFieldDotted( "collections.chunks" );
-
- string databaseHash1 = base.getFieldDotted( "collections.databases" );
- string databaseHash2 = res[i].getFieldDotted( "collections.databases" );
-
- string collectionsHash1 = base.getFieldDotted( "collections.collections" );
- string collectionsHash2 = res[i].getFieldDotted( "collections.collections" );
-
- string shardHash1 = base.getFieldDotted( "collections.shards" );
- string shardHash2 = res[i].getFieldDotted( "collections.shards" );
-
- string versionHash1 = base.getFieldDotted( "collections.version" );
- string versionHash2 = res[i].getFieldDotted( "collections.version" );
-
- if ( chunksHash1 == chunksHash2 &&
- databaseHash1 == databaseHash2 &&
- collectionsHash1 == collectionsHash2 &&
- shardHash1 == shardHash2 &&
- versionHash1 == versionHash2 ) {
- continue;
- }
-
- stringstream ss;
- ss << "config servers " << _config[firstGood] << " and " << _config[i] << " differ";
- warning() << ss.str() << endl;
- if ( tries <= 1 ) {
- ss << ": " << base["collections"].Obj() << " vs " << res[i]["collections"].Obj();
- errmsg = ss.str();
- return false;
- }
-
- return checkConfigServersConsistent( errmsg , tries - 1 );
- }
-
- return true;
- }
-
- bool ConfigServer::ok( bool checkConsistency ) {
- if ( ! _primary.ok() )
- return false;
-
- if ( checkConsistency ) {
- string errmsg;
- if ( ! checkConfigServersConsistent( errmsg ) ) {
- error() << "could not verify that config servers are in sync" << causedBy(errmsg) << warnings;
- return false;
- }
- }
-
- return true;
- }
-
int ConfigServer::dbConfigVersion() {
ScopedDbConnection conn(_primary.getConnString(), 30.0);
int version = dbConfigVersion( conn.conn() );