@@ -30,38 +30,26 @@ namespace mongo {
3030 return " IndexRebuilder" ;
3131 }
3232
33- /* *
34- * This resets memory tracking to its original value after all indexes are rebuilt.
35- *
36- * Before the server starts listening, all memory accesses are counted as taking 0 time (because
37- * the timer hasn't started yet). The Record class warns about these 0-time accesses (actually,
38- * the warning is in Rolling, which is used by Record) so run() turns off the tracking to
39- * silence these warnings. We want to make sure that they're turned back on, though, no matter
40- * how run() exits.
41- */
42- static void resetMemoryTracking (bool originalTracking) {
43- Record::MemoryTrackingEnabled = originalTracking;
44- }
45-
4633 void IndexRebuilder::run () {
47- // Disable record access timer warnings
48- ON_BLOCK_EXIT (resetMemoryTracking, Record::MemoryTrackingEnabled);
49- Record::MemoryTrackingEnabled = false ;
50-
5134 Client::initThread (name ().c_str ());
35+ ON_BLOCK_EXIT_OBJ (cc (), &Client::shutdown);
5236 Client::GodScope gs;
5337
5438 bool firstTime = true ;
5539 std::vector<std::string> dbNames;
5640 getDatabaseNames (dbNames);
5741
58- for (std::vector<std::string>::const_iterator it = dbNames.begin ();
59- it < dbNames.end ();
60- it++) {
61- checkDB (*it, &firstTime);
42+ try {
43+ for (std::vector<std::string>::const_iterator it = dbNames.begin ();
44+ it < dbNames.end ();
45+ it++) {
46+ checkDB (*it, &firstTime);
47+ }
6248 }
63-
64- cc ().shutdown ();
49+ catch (const DBException& e) {
50+ warning () << " index rebuilding did not complete" << endl;
51+ }
52+ LOG (1 ) << " checking complete" << endl;
6553 }
6654
6755 void IndexRebuilder::checkDB (const std::string& dbName, bool * firstTime) {
@@ -71,9 +59,9 @@ namespace mongo {
7159
7260 // This depends on system.namespaces not changing while we iterate
7361 while (cursor->more ()) {
74- BSONObj nsDoc = cursor->next ();
62+ BSONObj nsDoc = cursor->nextSafe ();
7563 const char * ns = nsDoc[" name" ].valuestrsafe ();
76-
64+ LOG ( 1 ) << " checking ns " << ns << " for interrupted index builds " << endl;
7765 // This write lock is held throughout the index building process
7866 // for this namespace.
7967 Client::WriteContext ctx (ns);
0 commit comments