Skip to content

Commit

Permalink
fix chunk cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Jul 7, 2011
1 parent 6f755db commit 9ff2f6c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions s/d_migrate.cpp
Expand Up @@ -190,13 +190,14 @@ namespace mongo {
class MigrateFromStatus { class MigrateFromStatus {
public: public:


MigrateFromStatus() : _m("MigrateFromStatus") { MigrateFromStatus() : _m("MigrateFromStatus") , _workLock( "MigrateFromStatus::WorkLock" ) {
_active = false; _active = false;
_inCriticalSection = false; _inCriticalSection = false;
_memoryUsed = 0; _memoryUsed = 0;
} }


void start( string ns , const BSONObj& min , const BSONObj& max ) { void start( string ns , const BSONObj& min , const BSONObj& max ) {
scoped_lock lk( _workLock );
scoped_lock l(_m); // reads and writes _active scoped_lock l(_m); // reads and writes _active


assert( ! _active ); assert( ! _active );
Expand Down Expand Up @@ -519,9 +520,10 @@ namespace mongo {
void doRemove( OldDataCleanup& cleanup ) { void doRemove( OldDataCleanup& cleanup ) {
while ( true ) { while ( true ) {
{ {
scoped_lock lk( _m ); scoped_lock lk( _workLock );
if ( ! _active ) { if ( ! _active ) {
cleanup.doRemove(); cleanup.doRemove();
return;
} }
} }
sleepmillis( 100 ); sleepmillis( 100 );
Expand Down Expand Up @@ -551,6 +553,9 @@ namespace mongo {
list<BSONObj> _deleted; // objects deleted during clone that should be deleted later list<BSONObj> _deleted; // objects deleted during clone that should be deleted later
long long _memoryUsed; // bytes in _reload + _deleted long long _memoryUsed; // bytes in _reload + _deleted


mutable mongo::mutex _workLock; // this is used to make sure only 1 thread is doing serious work
// for now, this means migrate or removing old chunk data

bool _getActive() const { scoped_lock l(_m); return _active; } bool _getActive() const { scoped_lock l(_m); return _active; }
void _setActive( bool b ) { scoped_lock l(_m); _active = b; } void _setActive( bool b ) { scoped_lock l(_m); _active = b; }


Expand Down

0 comments on commit 9ff2f6c

Please sign in to comment.