diff options
author | Greg Studer <greg@10gen.com> | 2014-03-13 11:26:10 -0400 |
---|---|---|
committer | Greg Studer <greg@10gen.com> | 2014-03-20 14:48:42 -0400 |
commit | d949d2f1c378a8230a2c24da4f1c431cca78a80c (patch) | |
tree | 5852264ecf90630f72ac7537b0634ba1f9c20ab5 /src/mongo/client/distlock.cpp | |
parent | 967120643015068ca8f60cde4bfbc2984da7bef1 (diff) | |
download | mongo-d949d2f1c378a8230a2c24da4f1c431cca78a80c.tar.gz |
SERVER-12548 add indexes to distlock collections backport
Diffstat (limited to 'src/mongo/client/distlock.cpp')
-rw-r--r-- | src/mongo/client/distlock.cpp | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/mongo/client/distlock.cpp b/src/mongo/client/distlock.cpp index 0e38a64f953..a2f56e564bf 100644 --- a/src/mongo/client/distlock.cpp +++ b/src/mongo/client/distlock.cpp @@ -131,19 +131,32 @@ namespace mongo { continue; } - // remove really old entries from the lockpings collection if they're not holding a lock - // (this may happen if an instance of a process was taken down and no new instance came up to - // replace it for a quite a while) - // if the lock is taken, the take-over mechanism should handle the situation - auto_ptr<DBClientCursor> c = conn->query( LocksType::ConfigNS , BSONObj() ); - // TODO: Would be good to make clear whether query throws or returns empty on errors - uassert( 16060, str::stream() << "cannot query locks collection on config server " << conn.getHost(), c.get() ); + // Remove really old entries from the lockpings collection if they're not + // holding a lock. This may happen if an instance of a process was taken down + // and no new instance came up to replace it for a quite a while. + // NOTE this is NOT the same as the standard take-over mechanism, which forces + // the lock entry. + BSONObj fieldsToReturn = BSON( LocksType::state() << 1 << + LocksType::process() << 1 ); + auto_ptr<DBClientCursor> activeLocks = + conn->query( LocksType::ConfigNS, + BSON( LocksType::state() << GT << 0 ) ); + + uassert( 16060, + str::stream() << "cannot query locks collection on config server " + << conn.getHost(), + activeLocks.get() ); set<string> pids; - while ( c->more() ) { - BSONObj lock = c->next(); - if ( ! lock[LocksType::process()].eoo() ) { - pids.insert( lock[LocksType::process()].valuestrsafe() ); + while ( activeLocks->more() ) { + BSONObj lock = activeLocks->nextSafe(); + + if ( !lock[LocksType::process()].eoo() ) { + pids.insert( lock[LocksType::process()].str() ); + } + else { + warning() << "found incorrect lock document during lock ping cleanup: " + << lock.toString() << endl; } } |