summaryrefslogtreecommitdiff
path: root/src/mongo/db/ttl.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2015-01-23 15:56:51 -0500
committerEliot Horowitz <eliot@10gen.com>2015-01-23 15:56:51 -0500
commit030f3710a74295707c5a0a788035005cb5013ab7 (patch)
tree870deb04258b127392d50ee7dfe47176a6dec4d9 /src/mongo/db/ttl.cpp
parentd8628625507b7a6927f21b1f1f91d68201fe4030 (diff)
downloadmongo-030f3710a74295707c5a0a788035005cb5013ab7.tar.gz
SERVER-17028: TTL Monitor has to handle WriteConflictException
Diffstat (limited to 'src/mongo/db/ttl.cpp')
-rw-r--r--src/mongo/db/ttl.cpp65
1 files changed, 38 insertions, 27 deletions
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp
index e75ee3e176b..a7b0367fd99 100644
--- a/src/mongo/db/ttl.cpp
+++ b/src/mongo/db/ttl.cpp
@@ -101,46 +101,57 @@ namespace mongo {
continue;
}
- // Count it as active from the moment the TTL thread wakes up
- OperationContextImpl txn;
+ try {
+ doTTLPass();
+ }
+ catch ( const WriteConflictException& e ) {
+ LOG(1) << "Got WriteConflictException in TTL thread";
+ }
- // if part of replSet but not in a readable state (e.g. during initial sync), skip.
- if (repl::getGlobalReplicationCoordinator()->getReplicationMode() ==
- repl::ReplicationCoordinator::modeReplSet &&
- !repl::getGlobalReplicationCoordinator()->getMemberState().readable())
- continue;
+ }
+ }
- set<string> dbs;
- dbHolder().getAllShortNames( dbs );
+ private:
+
+ void doTTLPass() {
+ // Count it as active from the moment the TTL thread wakes up
+ OperationContextImpl txn;
+
+ // if part of replSet but not in a readable state (e.g. during initial sync), skip.
+ if (repl::getGlobalReplicationCoordinator()->getReplicationMode() ==
+ repl::ReplicationCoordinator::modeReplSet &&
+ !repl::getGlobalReplicationCoordinator()->getMemberState().readable())
+ return;
- ttlPasses.increment();
+ set<string> dbs;
+ dbHolder().getAllShortNames( dbs );
- for ( set<string>::const_iterator i=dbs.begin(); i!=dbs.end(); ++i ) {
- string db = *i;
+ ttlPasses.increment();
- vector<BSONObj> indexes;
- getTTLIndexesForDB(&txn, db, &indexes);
+ for ( set<string>::const_iterator i=dbs.begin(); i!=dbs.end(); ++i ) {
+ string db = *i;
- for ( vector<BSONObj>::const_iterator it = indexes.begin();
- it != indexes.end(); ++it ) {
+ vector<BSONObj> indexes;
+ getTTLIndexesForDB(&txn, db, &indexes);
- BSONObj idx = *it;
- try {
- if ( !doTTLForIndex( &txn, db, idx ) ) {
- break; // stop processing TTL indexes on this database
- }
- } catch (const DBException& dbex) {
- error() << "Error processing ttl index: " << idx
- << " -- " << dbex.toString();
- // continue on to the next index
- continue;
+ for ( vector<BSONObj>::const_iterator it = indexes.begin();
+ it != indexes.end(); ++it ) {
+
+ BSONObj idx = *it;
+ try {
+ if ( !doTTLForIndex( &txn, db, idx ) ) {
+ break; // stop processing TTL indexes on this database
}
+ } catch (const DBException& dbex) {
+ error() << "Error processing ttl index: " << idx
+ << " -- " << dbex.toString();
+ // continue on to the next index
+ continue;
}
}
}
}
- private:
/**
* Acquire an IS-mode lock on the specified database and for each
* collection in the database, append the specification of all