summaryrefslogtreecommitdiff
path: root/s
diff options
context:
space:
mode:
Diffstat (limited to 's')
-rw-r--r--s/d_migrate.cpp57
-rw-r--r--s/d_state.cpp9
2 files changed, 48 insertions, 18 deletions
diff --git a/s/d_migrate.cpp b/s/d_migrate.cpp
index 731761f..918dd86 100644
--- a/s/d_migrate.cpp
+++ b/s/d_migrate.cpp
@@ -482,32 +482,53 @@ namespace mongo {
while ( 1 ) {
bool filledBuffer = false;
-
- readlock l( _ns );
- Client::Context ctx( _ns );
- scoped_spinlock lk( _trackerLocks );
- set<DiskLoc>::iterator i = _cloneLocs.begin();
- for ( ; i!=_cloneLocs.end(); ++i ) {
- if (tracker.ping()) // should I yield?
- break;
- DiskLoc dl = *i;
- BSONObj o = dl.obj();
+ auto_ptr<RWLockRecursive::Shared> fileLock;
+ Record* recordToTouch = NULL;
- // use the builder size instead of accumulating 'o's size so that we take into consideration
- // the overhead of BSONArray indices
- if ( a.len() + o.objsize() + 1024 > BSONObjMaxUserSize ) {
- filledBuffer = true; // break out of outer while loop
- break;
- }
+ {
+ readlock rlk(_ns);
+ Client::Context ctx( _ns ); // ReadContext?
+ scoped_spinlock lk( _trackerLocks );
+ set<DiskLoc>::iterator i = _cloneLocs.begin();
+ for ( ; i!=_cloneLocs.end(); ++i ) {
+ if (tracker.ping()) // should I yield?
+ break;
- a.append( o );
- }
+ DiskLoc dl = *i;
+ Record* r = dl.rec();
+ if ( ! r->likelyInPhysicalMemory() ) {
+ fileLock.reset( new RWLockRecursive::Shared( MongoFile::mmmutex) );
+ recordToTouch = r;
+ break;
+ }
+
+ BSONObj o = dl.obj();
+
+ // use the builder size instead of accumulating 'o's size so that we take into consideration
+ // the overhead of BSONArray indices
+ if ( a.len() + o.objsize() + 1024 > BSONObjMaxUserSize ) {
+ filledBuffer = true; // break out of outer while loop
+ break;
+ }
+
+ a.append( o );
+ }
_cloneLocs.erase( _cloneLocs.begin() , i );
if ( _cloneLocs.empty() || filledBuffer )
break;
+ }
+ if ( recordToTouch ) {
+ // its safe to touch here because we have a LockMongoFilesShared
+ // we can't do where we get the lock because we would have to unlock the main readlock and tne _trackerLocks
+ // simpler to handle this out there
+ recordToTouch->touch();
+ recordToTouch = NULL;
+ }
+
+
}
result.appendArray( "objects" , a.arr() );
diff --git a/s/d_state.cpp b/s/d_state.cpp
index 638d8c1..ef933a0 100644
--- a/s/d_state.cpp
+++ b/s/d_state.cpp
@@ -614,6 +614,15 @@ namespace mongo {
}
if ( globalVersion == 0 && ! authoritative ) {
+ // Needed b/c when the last chunk is moved off a shard, the version gets reset to zero, which
+ // should require a reload.
+ // TODO: Maybe a more elegant way of doing this
+ while ( shardingState.inCriticalMigrateSection() ) {
+ dbtemprelease r;
+ sleepmillis(2);
+ OCCASIONALLY log() << "waiting till out of critical section for version reset" << endl;
+ }
+
// need authoritative for first look
result.append( "ns" , ns );
result.appendBool( "need_authoritative" , true );