Browse files

SERVER-5142 use ticket holder instead of mutex to allow 3 parallel re…

…freshes, with 30s timeout
  • Loading branch information...
1 parent edc6a48 commit 8983591f83c0817d0bf46a29d338db910399d8e7 Greg Studer committed with erh Mar 6, 2012
Showing with 6 additions and 6 deletions.
  1. +1 −1 s/d_chunk_manager.cpp
  2. +2 −3 s/d_logic.h
  3. +3 −2 s/d_state.cpp
View
2 s/d_chunk_manager.cpp
@@ -40,7 +40,7 @@ namespace mongo {
conn = direct.get();
}
else {
- scoped.reset( new ScopedDbConnection( configServer ) );
+ scoped.reset( new ScopedDbConnection( configServer, 30.0 ) );
conn = scoped->get();
}
View
5 s/d_logic.h
@@ -148,9 +148,8 @@ namespace mongo {
// protects state below
mutable mongo::mutex _mutex;
// protects accessing the config server
- // can't use default _mutex b/c it's possible this shard is also the config server,
- // and we need to access the ShardingState to process new connections
- mutable mongo::mutex _configServerMutex;
+ // Using a ticket holder so we can have multiple redundant tries at any given time
+ mutable TicketHolder _configServerTickets;
// map from a namespace into the ensemble of chunk ranges that are stored in this mongod
// a ShardChunkManager carries all state we need for a collection at this shard, including its version information
View
5 s/d_state.cpp
@@ -45,7 +45,8 @@ namespace mongo {
// -----ShardingState START ----
ShardingState::ShardingState()
- : _enabled(false) , _mutex( "ShardingState" ), _configServerMutex( "_configServer_ShardingState" ) {
+ : _enabled(false) , _mutex( "ShardingState" ),
+ _configServerTickets( 3 /* max number of concurrent config server refresh threads */ ) {
}
void ShardingState::enable( const string& server ) {
@@ -192,7 +193,7 @@ namespace mongo {
LOG( 2 ) << "trying to set shard version of " << version.toString() << " for '" << ns << "'" << endl;
- scoped_lock clk( _configServerMutex );
+ TicketHolderReleaser needTicketFrom( &_configServerTickets );
// fast path - double-check if requested version is at the same version as this chunk manager before verifying
// against config server

0 comments on commit 8983591

Please sign in to comment.