diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-04-12 22:19:41 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-04-12 22:19:41 -0400 |
commit | 7d9eebe9830196475ae2034621ae1fb72a0bbbad (patch) | |
tree | 1bec052e22c8c8c1f17e3232b5dc00d8e2a579c7 /s | |
parent | 391f2f01b60d71f0532a2e3bfa9900a8109a22cb (diff) | |
download | mongo-7d9eebe9830196475ae2034621ae1fb72a0bbbad.tar.gz |
Sharding: fix part of old config resync
Diffstat (limited to 's')
-rw-r--r-- | s/request.cpp | 20 | ||||
-rw-r--r-- | s/request.h | 15 | ||||
-rw-r--r-- | s/strategy.cpp | 2 |
3 files changed, 28 insertions, 9 deletions
diff --git a/s/request.cpp b/s/request.cpp index e7a1a93367f..1a7556235b1 100644 --- a/s/request.cpp +++ b/s/request.cpp @@ -48,8 +48,10 @@ namespace mongo { else { _shardInfo = 0; } - } + _m.data->id = _id; + } + string Request::singleServerName(){ if ( _shardInfo ){ if ( _shardInfo->numShards() > 1 ) @@ -62,12 +64,15 @@ namespace mongo { } void Request::process( int attempt ){ - + + log(2) << "Request::process ns: " << getns() << " msg id:" << (int)(_m.data->id) << " attempt: " << attempt << endl; + int op = _m.data->operation(); assert( op > dbMsg ); Strategy * s = SINGLE; + _d.markSet(); if ( getConfig()->isPartitioned() && op == dbQuery ){ // there are a few things we need to check here // 1. db.eval @@ -75,7 +80,7 @@ namespace mongo { // will need to make it look at function later // 2. $where - can't access DB // TODO: make it smarter - + //cerr << "E1.b" << endl; QueryMessage q( _d ); BSONObj query = q.query; @@ -89,24 +94,25 @@ namespace mongo { if ( query.hasField( "$where" ) ) throw UserException( "$where not supported for partitioned databases yet" ); - _d.resetPull(); + _d.markReset(); } if ( _shardInfo ){ if ( _shardInfo->numShards() > 1 ) s = SHARDED; } - + if ( op == dbQuery ) { try { s->queryOp( *this ); } catch ( StaleConfigException& staleConfig ){ - log() << "got stale config exception ns:" << getns() << " attempt: " << attempt << endl; + log() << staleConfig.what() << " attempt: " << attempt << endl; uassert( "too many attempts to update config, failing" , attempt < 5 ); - + sleep( attempt ); reset( true ); + _d.markReset(); process( attempt + 1 ); return; } diff --git a/s/request.h b/s/request.h index 1aa1e326c04..a46d4b1411c 100644 --- a/s/request.h +++ b/s/request.h @@ -61,7 +61,7 @@ namespace mongo { private: - void reset( bool reload=true ); + void reset( bool reload=false ); Message& _m; DbMessage _d; @@ -73,7 +73,20 @@ namespace mongo { }; class StaleConfigException : public std::exception { + public: + StaleConfigException( const string& ns , const string& msg){ + stringstream s; + s << "StaleConfigException ns: " << ns << " " << msg; + _msg = s.str(); + } + + virtual ~StaleConfigException() throw(){} + virtual const char* what() const throw(){ + return _msg.c_str(); + } + private: + string _msg; }; } diff --git a/s/strategy.cpp b/s/strategy.cpp index 758cc6bec7b..2f3aad20bad 100644 --- a/s/strategy.cpp +++ b/s/strategy.cpp @@ -36,7 +36,7 @@ namespace mongo { { QueryResult *qr = (QueryResult *) response.data; if ( qr->resultFlags() & QueryResult::ResultFlag_ShardConfigStale ){ - throw StaleConfigException(); + throw StaleConfigException( r.getns() , "Strategy::doQuery" ); } } |