Permalink
Browse files

Use global lock when exiting critical section because it is greedier.…

… Also add verbose logging around exiting critical section. SERVER-7500 SERVER-7493
  • Loading branch information...
1 parent cb2e7e3 commit fed35f0c0829626dddeef23c3d9b9e373fe9353f @stbrody stbrody committed Nov 5, 2012
Showing with 15 additions and 7 deletions.
  1. +13 −6 src/mongo/s/d_migrate.cpp
  2. +2 −1 src/mongo/s/d_state.cpp
View
19 src/mongo/s/d_migrate.cpp
@@ -294,7 +294,10 @@ namespace mongo {
}
void done() {
- Lock::DBWrite lk( _ns );
+ log() << "MigrateFromStatus::done About to acquire global write lock to exit critical "
+ "section" << endl;
+ Lock::GlobalWrite lk;
+ log() << "MigrateFromStatus::done Global lock acquired" << endl;
{
scoped_spinlock lk( _trackerLocks );
@@ -1120,7 +1123,8 @@ namespace mongo {
{
BSONObj res;
scoped_ptr<ScopedDbConnection> connTo(
- ScopedDbConnection::getScopedDbConnection( toShard.getConnString() ) );
+ ScopedDbConnection::getScopedDbConnection( toShard.getConnString(),
+ 35.0 ) );
bool ok;
@@ -1138,15 +1142,18 @@ namespace mongo {
connTo->done();
if ( ! ok ) {
+ log() << "moveChunk migrate commit not accepted by TO-shard: " << res
+ << " resetting shard version to: " << startingVersion << migrateLog;
{
- Lock::DBWrite lk( ns );
+ Lock::GlobalWrite lk;
+ log() << "moveChunk global lock acquired to reset shard version from "
+ "failed migration" << endl;
// revert the chunk manager back to the state before "forgetting" about the chunk
shardingState.undoDonateChunk( ns , min , max , startingVersion );
}
-
- log() << "moveChunk migrate commit not accepted by TO-shard: " << res
- << " resetting shard version to: " << startingVersion << migrateLog;
+ log() << "Shard version successfully reset to clean up failed migration"
+ << endl;
errmsg = "_recvChunkCommit failed!";
result.append( "cause" , res );
View
3 src/mongo/s/d_state.cpp
@@ -162,6 +162,7 @@ namespace mongo {
void ShardingState::undoDonateChunk( const string& ns , const BSONObj& min , const BSONObj& max , ShardChunkVersion version ) {
scoped_lock lk( _mutex );
+ log() << "ShardingState::undoDonateChunk acquired _mutex" << endl;
ChunkManagersMap::const_iterator it = _chunks.find( ns );
verify( it != _chunks.end() ) ;
@@ -634,7 +635,7 @@ namespace mongo {
if ( version < globalVersion && version.hasCompatibleEpoch( globalVersion ) ) {
while ( shardingState.inCriticalMigrateSection() ) {
dbtemprelease r;
- sleepmillis(2);
+ sleepmillis(20);
OCCASIONALLY log() << "waiting till out of critical section" << endl;
}
errmsg = "shard global version for collection is higher than trying to set to '" + ns + "'";

0 comments on commit fed35f0

Please sign in to comment.