summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@10gen.com>2012-11-05 14:19:11 -0500
committerSpencer T Brody <spencer@10gen.com>2012-11-16 17:36:46 -0500
commitfed35f0c0829626dddeef23c3d9b9e373fe9353f (patch)
treece4e8c9199b59c31c1137c9b2cc8496f48d934fe
parentcb2e7e34d5a2dddeba4eaffece4af7fadcf615a2 (diff)
downloadmongo-fed35f0c0829626dddeef23c3d9b9e373fe9353f.tar.gz
Use global lock when exiting critical section because it is greedier. Also add verbose logging around exiting critical section. SERVER-7500 SERVER-7493
-rw-r--r--src/mongo/s/d_migrate.cpp19
-rw-r--r--src/mongo/s/d_state.cpp3
2 files changed, 15 insertions, 7 deletions
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index db7c2c055af..479e9ad1085 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/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 );
diff --git a/src/mongo/s/d_state.cpp b/src/mongo/s/d_state.cpp
index 7cf31358b19..37adfe8131b 100644
--- a/src/mongo/s/d_state.cpp
+++ b/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 + "'";