Skip to content

Commit

Permalink
SERVER-8344 Rebuild indexes before listening
Browse files Browse the repository at this point in the history
  • Loading branch information
kchodorow committed Feb 11, 2013
1 parent 8813bd3 commit 39d99f0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/mongo/db/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ namespace mongo {
/* this is for security on certain platforms (nonce generation) */
srand((unsigned) (curTimeMicros() ^ startupSrandTimer.micros()));

indexRebuilder.go();
indexRebuilder.run();

snapshotThread.go();
d.clientCursorMonitor.go();
Expand Down
13 changes: 3 additions & 10 deletions src/mongo/db/index_rebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ namespace mongo {

IndexRebuilder::IndexRebuilder() {}

std::string IndexRebuilder::name() const {
return "IndexRebuilder";
}

/**
* This resets memory tracking to its original value after all indexes are rebuilt.
*
Expand All @@ -48,14 +44,11 @@ namespace mongo {
ON_BLOCK_EXIT(resetMemoryTracking, Record::MemoryTrackingEnabled);
Record::MemoryTrackingEnabled = false;

Client::initThread(name().c_str());
Client::GodScope gs;
std::vector<std::string> dbNames;
Lock::GlobalWrite lk;

{
Lock::GlobalWrite lk;
getDatabaseNames(dbNames);
}
std::vector<std::string> dbNames;
getDatabaseNames(dbNames);

for (std::vector<std::string>::const_iterator it = dbNames.begin();
it < dbNames.end();
Expand Down
3 changes: 1 addition & 2 deletions src/mongo/db/index_rebuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
#pragma once

#include "mongo/db/namespace_details.h"
#include "mongo/util/background.h"

namespace mongo {

class IndexRebuilder : public BackgroundJob {
class IndexRebuilder {
public:
IndexRebuilder();

Expand Down
7 changes: 0 additions & 7 deletions src/mongo/db/repl/rs_rollback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "mongo/db/client.h"
#include "mongo/db/cloner.h"
#include "mongo/db/index_rebuilder.h"
#include "mongo/db/ops/update.h"
#include "mongo/db/ops/delete.h"
#include "mongo/db/repl/rs.h"
Expand Down Expand Up @@ -575,12 +574,6 @@ namespace mongo {
}

void ReplSetImpl::syncRollback(OplogReader&r) {
// If this is startup, wait for any index build retries to finish first
while (indexRebuilder.getState() != BackgroundJob::Done) {
OCCASIONALLY LOG(0) << "replSet rollback waiting for index rebuild to finish" << endl;
indexRebuilder.wait(1000);
}

// check that we are at minvalid, otherwise we cannot rollback as we may be in an
// inconsistent state
{
Expand Down

0 comments on commit 39d99f0

Please sign in to comment.