Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix chunk cleaning

  • Loading branch information...
commit 9ff2f6ce50b3caddcee7c43fffd3136e8c354270 1 parent 6f755db
Eliot authored

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. 9  s/d_migrate.cpp
9  s/d_migrate.cpp
@@ -190,13 +190,14 @@ namespace mongo {
190 190
     class MigrateFromStatus {
191 191
     public:
192 192
 
193  
-        MigrateFromStatus() : _m("MigrateFromStatus") {
  193
+        MigrateFromStatus() : _m("MigrateFromStatus") , _workLock( "MigrateFromStatus::WorkLock" ) {
194 194
             _active = false;
195 195
             _inCriticalSection = false;
196 196
             _memoryUsed = 0;
197 197
         }
198 198
 
199 199
         void start( string ns , const BSONObj& min , const BSONObj& max ) {
  200
+            scoped_lock lk( _workLock );
200 201
             scoped_lock l(_m); // reads and writes _active
201 202
 
202 203
             assert( ! _active );
@@ -519,9 +520,10 @@ namespace mongo {
519 520
         void doRemove( OldDataCleanup& cleanup ) {
520 521
             while ( true ) { 
521 522
                 {
522  
-                    scoped_lock lk( _m );
  523
+                    scoped_lock lk( _workLock );
523 524
                     if ( ! _active ) {
524 525
                         cleanup.doRemove();
  526
+                        return;
525 527
                     }
526 528
                 }
527 529
                 sleepmillis( 100 );
@@ -551,6 +553,9 @@ namespace mongo {
551 553
         list<BSONObj> _deleted; // objects deleted during clone that should be deleted later
552 554
         long long _memoryUsed; // bytes in _reload + _deleted
553 555
 
  556
+        mutable mongo::mutex _workLock; // this is used to make sure only 1 thread is doing serious work
  557
+                                        // for now, this means migrate or removing old chunk data
  558
+
554 559
         bool _getActive() const { scoped_lock l(_m); return _active; }
555 560
         void _setActive( bool b ) { scoped_lock l(_m); _active = b; }
556 561
 

0 notes on commit 9ff2f6c

Please sign in to comment.
Something went wrong with that request. Please try again.