diff options
author | Geert Bosch <geert@mongodb.com> | 2014-12-15 13:33:17 -0500 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2014-12-16 09:54:59 -0500 |
commit | fd08ed58f4d3ffe284e1d28d9ebe44ab10ffbe6f (patch) | |
tree | 89eaf90f7eb15e4323e5d6bea870eecc975f5c33 /src/mongo/db/ttl.cpp | |
parent | 9eaafcaff45ac51a1f924e0562ad8e3f21318e34 (diff) | |
download | mongo-fd08ed58f4d3ffe284e1d28d9ebe44ab10ffbe6f.tar.gz |
SERVER-16501: Uncaught WriteConflictException in TTLMonitor
Diffstat (limited to 'src/mongo/db/ttl.cpp')
-rw-r--r-- | src/mongo/db/ttl.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/mongo/db/ttl.cpp b/src/mongo/db/ttl.cpp index 8d0836b045e..7af17cb41d5 100644 --- a/src/mongo/db/ttl.cpp +++ b/src/mongo/db/ttl.cpp @@ -41,6 +41,7 @@ #include "mongo/db/client.h" #include "mongo/db/commands/fsync.h" #include "mongo/db/commands/server_status_metric.h" +#include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/catalog/collection_catalog_entry.h" #include "mongo/db/catalog/database_catalog_entry.h" #include "mongo/db/catalog/database_holder.h" @@ -205,8 +206,9 @@ namespace mongo { LOG(1) << "TTL: " << key << " \t " << query << endl; - long long n = 0; - { + long long numDeleted = 0; + int attempt = 1; + while (1) { const string ns = idx["ns"].String(); ScopedTransaction scopedXact(txn, MODE_IX); @@ -236,11 +238,23 @@ namespace mongo { return true; } - n = deleteObjects( txn, db, ns, query, PlanExecutor::YIELD_AUTO, false, true ); - ttlDeletedDocuments.increment( n ); + try { + numDeleted = deleteObjects(txn, + db, + ns, + query, + PlanExecutor::YIELD_AUTO, + false, + true); + break; + } + catch (const WriteConflictException& dle) { + WriteConflictException::logAndBackoff(attempt++, "ttl", ns); + } } - LOG(1) << "\tTTL deleted: " << n << endl; + ttlDeletedDocuments.increment(numDeleted); + LOG(1) << "\tTTL deleted: " << numDeleted << endl; return true; } }; |