summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristina <kristina@10gen.com>2012-11-12 11:50:12 -0500
committerKristina <kristina@10gen.com>2012-11-12 11:50:12 -0500
commit3abcc53d43145bcda52016c753e10ff139d41e4d (patch)
tree8ed28904a6e433949420ccd9229e6d9721eaa4d9 /src
parent074431815cdfc44ad757675a159e3e51739d1d95 (diff)
downloadmongo-3abcc53d43145bcda52016c753e10ff139d41e4d.tar.gz
Revert "SERVER-2771 Retry index builds on startup"
This reverts commit ab9ff1d3ecc7163fc93188efd997bbacd8fe7406.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/SConscript1
-rw-r--r--src/mongo/db/cmdline.h5
-rw-r--r--src/mongo/db/db.cpp26
-rw-r--r--src/mongo/db/index_rebuilder.cpp112
-rw-r--r--src/mongo/db/index_rebuilder.h45
-rw-r--r--src/mongo/db/index_update.cpp28
-rw-r--r--src/mongo/db/namespace_details.cpp35
-rw-r--r--src/mongo/db/namespace_details.h16
-rw-r--r--src/mongo/db/pdfile.cpp70
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp20
-rw-r--r--src/mongo/dbtests/clienttests.cpp43
11 files changed, 106 insertions, 295 deletions
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 91d3155f61d..856453bcc63 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -344,7 +344,6 @@ serverOnlyFiles = [ "db/curop.cpp",
"db/extsort.cpp",
"db/index.cpp",
"db/index_update.cpp",
- "db/index_rebuilder.cpp",
"db/scanandorder.cpp",
"db/explain.cpp",
"db/geo/2d.cpp",
diff --git a/src/mongo/db/cmdline.h b/src/mongo/db/cmdline.h
index c30e30d04ea..535138d8319 100644
--- a/src/mongo/db/cmdline.h
+++ b/src/mongo/db/cmdline.h
@@ -72,7 +72,6 @@ namespace mongo {
bool usingReplSets() const { return !_replSet.empty(); }
std::string rsIndexPrefetch;// --indexPrefetch
- bool indexBuildRetry; // --noIndexBuildRetry
// for master/slave replication
std::string source; // --source
@@ -142,7 +141,7 @@ namespace mongo {
SSLManager* sslServerManager; // currently leaks on close
#endif
-
+
static void launchOk();
static void addGlobalOptions( boost::program_options::options_description& general ,
@@ -177,7 +176,7 @@ namespace mongo {
// todo move to cmdline.cpp?
inline CmdLine::CmdLine() :
- port(DefaultDBPort), rest(false), jsonp(false), indexBuildRetry(true), quiet(false),
+ port(DefaultDBPort), rest(false), jsonp(false), quiet(false),
noTableScan(false), prealloc(true), preallocj(true), smallfiles(sizeof(int*) == 4),
configsvr(false), quota(false), quotaFiles(8), cpu(false),
durOptions(0), objcheck(false), oplogSize(0), defaultProfile(0),
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 9eceb6de07b..c2f489854bd 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -34,7 +34,6 @@
#include "mongo/db/dbmessage.h"
#include "mongo/db/dbwebserver.h"
#include "mongo/db/dur.h"
-#include "mongo/db/index_rebuilder.h"
#include "mongo/db/initialize_server_global_state.h"
#include "mongo/db/instance.h"
#include "mongo/db/introspect.h"
@@ -79,6 +78,7 @@ namespace mongo {
extern int diagLogging;
extern unsigned lenForNewNsFiles;
extern int lockFile;
+ extern bool checkNsFilesOnLoad;
extern string repairpath;
void setupSignals( bool inFork );
@@ -294,6 +294,9 @@ namespace mongo {
Client::GodScope gs;
LOG(1) << "enter repairDatabases (to check pdfile version #)" << endl;
+ //verify(checkNsFilesOnLoad);
+ checkNsFilesOnLoad = false; // we are mainly just checking the header - don't scan the whole .ns file for every db here.
+
Lock::GlobalWrite lk;
vector< string > dbNames;
getDatabaseNames( dbNames );
@@ -342,6 +345,8 @@ namespace mongo {
cc().shutdown();
dbexit( EXIT_CLEAN );
}
+
+ checkNsFilesOnLoad = true;
}
void clearTmpFiles() {
@@ -398,7 +403,7 @@ namespace mongo {
*/
class DataFileSync : public BackgroundJob , public ServerStatusSection {
public:
- DataFileSync()
+ DataFileSync()
: ServerStatusSection( "backgroundFlushing" ),
_total_time( 0 ),
_flushes( 0 ),
@@ -407,7 +412,7 @@ namespace mongo {
virtual bool includeByDefault() const { return true; }
virtual bool adminOnly() const { return false; }
-
+
string name() const { return "DataFileSync"; }
void run() {
@@ -464,7 +469,7 @@ namespace mongo {
_last_time = ms;
_last = jsTime();
}
-
+
long long _total_time;
long long _flushes;
int _last_time;
@@ -480,16 +485,16 @@ namespace mongo {
virtual void appendAtLeaf( BSONObjBuilder& b ) const {
int m = static_cast<int>(MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ));
b.appendNumber( "mapped" , m );
-
+
if ( cmdLine.dur ) {
m *= 2;
b.appendNumber( "mappedWithJournal" , m );
}
-
+
}
} memJournalServerStatusMetric;
}
-
+
const char * jsInterruptCallback() {
// should be safe to interrupt in js code, even if we have a write lock
@@ -635,8 +640,6 @@ namespace mongo {
/* this is for security on certain platforms (nonce generation) */
srand((unsigned) (curTimeMicros() ^ startupSrandTimer.micros()));
- indexRebuilder.go();
-
snapshotThread.go();
d.clientCursorMonitor.go();
PeriodicTask::theRunner->go();
@@ -751,8 +754,6 @@ static void buildOptionsDescriptions(po::options_description *pVisible,
("jsonp","allow JSONP access via http (has security implications)")
("noauth", "run without security")
("nohttpinterface", "disable http interface")
- ("noIndexBuildRetry", po::value<int>(),
- "don't retry any index builds that were interrupted by shutdown")
("nojournal", "disable journaling (journaling is on by default for 64 bit)")
("noprealloc", "disable data file preallocation - will often hurt performance")
("noscripting", "disable scripting engine")
@@ -1036,9 +1037,6 @@ static void processCommandLineOptions(const std::vector<std::string>& argv) {
if (params.count("replIndexPrefetch")) {
cmdLine.rsIndexPrefetch = params["replIndexPrefetch"].as<std::string>();
}
- if (params.count("noIndexBuildRetry")) {
- cmdLine.indexBuildRetry = false;
- }
if (params.count("only")) {
cmdLine.only = params["only"].as<string>().c_str();
}
diff --git a/src/mongo/db/index_rebuilder.cpp b/src/mongo/db/index_rebuilder.cpp
deleted file mode 100644
index 5ae2b389510..00000000000
--- a/src/mongo/db/index_rebuilder.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * Copyright (C) 2012 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "mongo/db/index_rebuilder.h"
-
-#include "mongo/db/instance.h"
-#include "mongo/db/pdfile.h"
-
-namespace mongo {
-
- IndexRebuilder indexRebuilder;
-
- IndexRebuilder::IndexRebuilder() {}
-
- std::string IndexRebuilder::name() const {
- return "IndexRebuilder";
- }
-
- void IndexRebuilder::run() {
- Client::initThread(name().c_str());
- Lock::GlobalWrite lk;
- Client::GodScope gs;
- std::vector<std::string> dbNames;
- getDatabaseNames(dbNames);
-
- for (std::vector<std::string>::const_iterator it = dbNames.begin();
- it < dbNames.end();
- it++) {
- checkDB(*it);
- }
-
- cc().shutdown();
- }
-
- void IndexRebuilder::checkDB(const std::string& dbName) {
- const std::string systemNS = dbName + ".system.namespaces";
- DBDirectClient cli;
- scoped_ptr<DBClientCursor> cursor(cli.query(systemNS, Query()));
-
- while (cursor->more()) {
- BSONObj nsDoc = cursor->next();
- const char* ns = nsDoc["name"].valuestrsafe();
-
- Client::Context ctx(ns, dbpath, false, false);
- NamespaceDetails* nsd = nsdetails(ns);
-
- if (!nsd || !nsd->indexBuildInProgress) {
- continue;
- }
-
- log() << "Found interrupted index build on " << ns << endl;
-
- // If the indexBuildRetry flag isn't set, just clear the inProg flag
- if (!cmdLine.indexBuildRetry) {
- // If we crash between unsetting the inProg flag and cleaning up the index, the
- // index space will be lost.
- getDur().writingInt(nsd->indexBuildInProgress) = 0;
- nsd->idx(nsd->nIndexes).kill_idx();
- continue;
- }
-
- retryIndexBuild(dbName, nsd);
- }
- }
-
- void IndexRebuilder::retryIndexBuild(const std::string& dbName, NamespaceDetails* nsd) {
- // details.info is always a valid system.indexes entry because DataFileMgr::insert journals
- // creating the index doc and then insert_makeIndex durably assigns its DiskLoc to info.
- // indexBuildInProgress is set after that, so if it is set, info must be set.
- IndexDetails& details = nsd->idx(nsd->nIndexes);
-
- // First, clean up the in progress index build. Save the system.indexes entry so that we
- // can add it again afterwards.
- BSONObj indexObj = details.info.obj().getOwned();
-
- // Clean up the in-progress index build
- getDur().writingInt(nsd->indexBuildInProgress) = 0;
- details.kill_idx();
- // The index has now been removed from system.indexes, so the only record of it is in-
- // memory. If there is a journal commit between now and when insert() rewrites the entry and
- // the db crashes before the new system.indexes entry is journalled, the index will be lost
- // forever. Thus, we're assuming no journaling will happen between now and the entry being
- // re-written.
-
- // We need to force a foreground index build to prevent replication from replaying an
- // incompatible op (like a drop) during a yield.
- // TODO: once commands can interrupt/wait for index builds, this can be removed.
- indexObj = indexObj.removeField("background");
-
- try {
- const std::string ns = dbName + ".system.indexes";
- theDataFileMgr.insert(ns.c_str(), indexObj.objdata(), indexObj.objsize(), false, true);
- }
- catch (const DBException& e) {
- log() << "Rebuilding index failed: " << e.what() << " (" << e.getCode() << ")"
- << endl;
- }
- }
-}
diff --git a/src/mongo/db/index_rebuilder.h b/src/mongo/db/index_rebuilder.h
deleted file mode 100644
index 3fd308f9cc9..00000000000
--- a/src/mongo/db/index_rebuilder.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright (C) 2012 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include "mongo/db/namespace_details.h"
-#include "mongo/util/background.h"
-
-namespace mongo {
-
- class IndexRebuilder : public BackgroundJob {
- public:
- IndexRebuilder();
-
- std::string name() const;
- void run();
-
- private:
- /**
- * Check each collection in a database to see if it has any in-progress index builds that
- * need to be retried. If so, calls retryIndexBuild.
- */
- void checkDB(const std::string& dbname);
-
- /**
- * Actually retry the index build on a given namespace.
- */
- void retryIndexBuild(const std::string& dbName, NamespaceDetails* nsd);
- };
-
- extern IndexRebuilder indexRebuilder;
-}
diff --git a/src/mongo/db/index_update.cpp b/src/mongo/db/index_update.cpp
index 107465bf14b..0e268b8ce61 100644
--- a/src/mongo/db/index_update.cpp
+++ b/src/mongo/db/index_update.cpp
@@ -515,6 +515,29 @@ namespace mongo {
}
};
+ /**
+ * For the lifetime of this object, an index build is indicated on the specified
+ * namespace and the newest index is marked as absent. This simplifies
+ * the cleanup required on recovery.
+ */
+ class RecoverableIndexState {
+ public:
+ RecoverableIndexState( NamespaceDetails *d ) : _d( d ) {
+ indexBuildInProgress() = 1;
+ nIndexes()--;
+ }
+ ~RecoverableIndexState() {
+ DESTRUCTOR_GUARD (
+ nIndexes()++;
+ indexBuildInProgress() = 0;
+ )
+ }
+ private:
+ int &nIndexes() { return getDur().writingInt( _d->nIndexes ); }
+ int &indexBuildInProgress() { return getDur().writingInt( _d->indexBuildInProgress ); }
+ NamespaceDetails *_d;
+ };
+
// throws DBException
void buildAnIndex(const std::string& ns,
NamespaceDetails* d,
@@ -527,7 +550,9 @@ namespace mongo {
unsigned long long n;
verify( !BackgroundOperation::inProgForNs(ns.c_str()) ); // should have been checked earlier, better not be...
+ verify( d->indexBuildInProgress == 0 );
verify( Lock::isWriteLocked(ns) );
+ RecoverableIndexState recoverable( d );
// Build index spec here in case the collection is empty and the index details are invalid
idx.getSpec();
@@ -651,8 +676,7 @@ namespace mongo {
d->nIndexes = 0;
}
if ( idIndex ) {
- d->getNextIndexDetails(ns) = *idIndex;
- d->addIndex(ns);
+ d->addIndex(ns) = *idIndex;
wassert( d->nIndexes == 1 );
}
/* assuming here that id index is not multikey: */
diff --git a/src/mongo/db/namespace_details.cpp b/src/mongo/db/namespace_details.cpp
index bd38b666f3e..931f44c8745 100644
--- a/src/mongo/db/namespace_details.cpp
+++ b/src/mongo/db/namespace_details.cpp
@@ -120,6 +120,28 @@ namespace mongo {
}
#endif
+ void NamespaceDetails::onLoad(const Namespace& k) {
+
+ if( k.isExtra() ) {
+ /* overflow storage for indexes - so don't treat as a NamespaceDetails object. */
+ return;
+ }
+
+ if( indexBuildInProgress ) {
+ verify( Lock::isW() ); // TODO(erh) should this be per db?
+ if( indexBuildInProgress ) {
+ log() << "indexBuildInProgress was " << indexBuildInProgress << " for " << k << ", indicating an abnormal db shutdown" << endl;
+ getDur().writingInt( indexBuildInProgress ) = 0;
+ }
+ }
+ }
+
+ static void namespaceOnLoadCallback(const Namespace& k, NamespaceDetails& v) {
+ v.onLoad(k);
+ }
+
+ bool checkNsFilesOnLoad = true;
+
NOINLINE_DECL void NamespaceIndex::_init() {
verify( !ht );
@@ -172,6 +194,8 @@ namespace mongo {
verify( len <= 0x7fffffff );
ht = new HashTable<Namespace,NamespaceDetails>(p, (int) len, "namespace index");
+ if( checkNsFilesOnLoad )
+ ht->iterAll(namespaceOnLoadCallback);
}
static void namespaceGetNamespacesCallback( const Namespace& k , NamespaceDetails& v , void * extra ) {
@@ -499,7 +523,8 @@ namespace mongo {
NamespaceDetailsTransient::get(thisns).clearQueryCache();
}
- IndexDetails& NamespaceDetails::getNextIndexDetails(const char* thisns) {
+ /* you MUST call when adding an index. see pdfile.cpp */
+ IndexDetails& NamespaceDetails::addIndex(const char *thisns, bool resetTransient) {
IndexDetails *id;
try {
id = &idx(nIndexes,true);
@@ -508,13 +533,11 @@ namespace mongo {
allocExtra(thisns, nIndexes);
id = &idx(nIndexes,false);
}
- return *id;
- }
- /* you MUST call when adding an index. see pdfile.cpp */
- void NamespaceDetails::addIndex(const char* thisns) {
(*getDur().writing(&nIndexes))++;
- NamespaceDetailsTransient::get(thisns).addedIndex();
+ if ( resetTransient )
+ NamespaceDetailsTransient::get(thisns).addedIndex();
+ return *id;
}
// must be called when renaming a NS to fix up extra
diff --git a/src/mongo/db/namespace_details.h b/src/mongo/db/namespace_details.h
index ab11728b86f..108d3fe2c8f 100644
--- a/src/mongo/db/namespace_details.h
+++ b/src/mongo/db/namespace_details.h
@@ -138,6 +138,9 @@ namespace mongo {
Extra* allocExtra(const char *ns, int nindexessofar);
void copyingFrom(const char *thisns, NamespaceDetails *src); // must be called when renaming a NS to fix up extra
+ /* called when loaded from disk */
+ void onLoad(const Namespace& k);
+
/* dump info on this namespace. for debugging. */
void dump(const Namespace& k);
@@ -223,17 +226,10 @@ namespace mongo {
bool isMultikey(int i) const { return (multiKeyIndexBits & (((unsigned long long) 1) << i)) != 0; }
void setIndexIsMultikey(const char *thisns, int i);
- /**
- * This fetches the IndexDetails for the next empty index slot. The caller must populate
- * returned object. This handles allocating extra index space, if necessary.
- */
- IndexDetails& getNextIndexDetails(const char* thisns);
-
- /**
- * Add a new index. This does not add it to system.indexes etc. - just to NamespaceDetails.
- * This resets the transient namespace details.
+ /* add a new index. does not add to system.indexes etc. - just to NamespaceDetails.
+ caller must populate returned object.
*/
- void addIndex(const char* thisns);
+ IndexDetails& addIndex(const char *thisns, bool resetTransient=true);
void aboutToDeleteAnIndex() {
clearSystemFlag( Flag_HaveIdIndex );
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp
index 6576c03ddef..8a68a3d0b70 100644
--- a/src/mongo/db/pdfile.cpp
+++ b/src/mongo/db/pdfile.cpp
@@ -1404,58 +1404,36 @@ namespace mongo {
}
int idxNo = tableToIndex->nIndexes;
-
+ IndexDetails& idx = tableToIndex->addIndex(tabletoidxns.c_str(), !background); // clear transient info caches so they refresh; increments nIndexes
+ getDur().writingDiskLoc(idx.info) = loc;
try {
- IndexDetails& idx = tableToIndex->getNextIndexDetails(tabletoidxns.c_str());
- // It's important that this is outside the inner try/catch so that we never try to call
- // kill_idx on a half-formed disk loc (if this asserts).
- getDur().writingDiskLoc(idx.info) = loc;
-
- try {
- getDur().writingInt(tableToIndex->indexBuildInProgress) = 1;
- buildAnIndex(tabletoidxns, tableToIndex, idx, idxNo, background, mayInterrupt);
+ buildAnIndex(tabletoidxns, tableToIndex, idx, idxNo, background, mayInterrupt);
+ }
+ catch( DBException& e ) {
+ // save our error msg string as an exception or dropIndexes will overwrite our message
+ LastError *le = lastError.get();
+ int savecode = 0;
+ string saveerrmsg;
+ if ( le ) {
+ savecode = le->code;
+ saveerrmsg = le->msg;
}
- catch (DBException& e) {
- // save our error msg string as an exception or dropIndexes will overwrite our message
- LastError *le = lastError.get();
- int savecode = 0;
- string saveerrmsg;
- if ( le ) {
- savecode = le->code;
- saveerrmsg = le->msg;
- }
- else {
- savecode = e.getCode();
- saveerrmsg = e.what();
- }
-
- // roll back this index
- idx.kill_idx();
-
- verify(le && !saveerrmsg.empty());
- setLastError(savecode,saveerrmsg.c_str());
- throw;
+ else {
+ savecode = e.getCode();
+ saveerrmsg = e.what();
}
- // clear transient info caches so they refresh; increments nIndexes
- tableToIndex->addIndex(tabletoidxns.c_str());
- getDur().writingInt(tableToIndex->indexBuildInProgress) = 0;
- }
- catch (...) {
- // Generally, this will be called as an exception from building the index bubbles up.
- // Thus, the index will have already been cleaned up. This catch just ensures that the
- // metadata is consistent on any exception. It may leak like a sieve if the index
- // successfully finished building and addIndex or kill_idx threw.
-
- // Check if nIndexes was incremented
- if (idxNo < tableToIndex->nIndexes) {
- // TODO: this will have to change when we can have multiple simultanious index
- // builds
- getDur().writingInt(tableToIndex->nIndexes) -= 1;
+ // roll back this index
+ string name = idx.indexName();
+ BSONObjBuilder b;
+ string errmsg;
+ bool ok = dropIndexes(tableToIndex, tabletoidxns.c_str(), name.c_str(), errmsg, b, true);
+ if( !ok ) {
+ log() << "failed to drop index after a unique key error building it: " << errmsg << ' ' << tabletoidxns << ' ' << name << endl;
}
- getDur().writingInt(tableToIndex->indexBuildInProgress) = 0;
-
+ verify( le && !saveerrmsg.empty() );
+ setLastError(savecode,saveerrmsg.c_str());
throw;
}
}
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 8a01885071c..6c653f32e79 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -16,14 +16,12 @@
*/
#include "pch.h"
-
-#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"
-#include "mongo/db/repl.h"
+#include "../client.h"
+#include "rs.h"
+#include "../repl.h"
+#include "../cloner.h"
+#include "../ops/update.h"
+#include "../ops/delete.h"
/* Scenarios
@@ -575,12 +573,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
{
diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp
index cf32f78cb2e..bfc5d60e228 100644
--- a/src/mongo/dbtests/clienttests.cpp
+++ b/src/mongo/dbtests/clienttests.cpp
@@ -17,11 +17,9 @@
// client.cpp
#include "pch.h"
-
#include "dbtests.h"
+#include "../db/d_concurrency.h"
#include "mongo/client/dbclientcursor.h"
-#include "mongo/db/d_concurrency.h"
-#include "mongo/db/pdfile.h"
namespace ClientTests {
@@ -29,7 +27,6 @@ namespace ClientTests {
public:
Base( string coll ) {
- db.dropDatabase("test");
_ns = (string)"test." + coll;
}
@@ -101,43 +98,6 @@ namespace ClientTests {
};
- /**
- * Check that nIndexes is incremented correctly when an index builds (and that it is not
- * incremented when an index fails to build), system.indexes has an entry added (or not), and
- * system.namespaces has a doc added (or not).
- */
- class BuildIndex : public Base {
- public:
- BuildIndex() : Base("buildIndex") {}
- void run() {
- Lock::DBWrite lock(ns());
- Client::WriteContext ctx(ns());
-
- db.insert(ns(), BSON("x" << 1 << "y" << 2));
- db.insert(ns(), BSON("x" << 2 << "y" << 2));
-
- ASSERT_EQUALS(1, nsdetails(ns())->nIndexes);
- // _id index
- ASSERT_EQUALS(1U, db.count("test.system.indexes"));
- // test.buildindex
- // test.buildindex_$id
- // test.system.indexes
- ASSERT_EQUALS(3U, db.count("test.system.namespaces"));
-
- db.ensureIndex(ns(), BSON("y" << 1), true);
-
- ASSERT_EQUALS(1, nsdetails(ns())->nIndexes);
- ASSERT_EQUALS(1U, db.count("test.system.indexes"));
- ASSERT_EQUALS(3U, db.count("test.system.namespaces"));
-
- db.ensureIndex(ns(), BSON("x" << 1), true);
-
- ASSERT_EQUALS(2, nsdetails(ns())->nIndexes);
- ASSERT_EQUALS(2U, db.count("test.system.indexes"));
- ASSERT_EQUALS(4U, db.count("test.system.namespaces"));
- }
- };
-
class CS_10 : public Base {
public:
CS_10() : Base( "CS_10" ) {}
@@ -227,7 +187,6 @@ namespace ClientTests {
add<DropIndex>();
add<ReIndex>();
add<ReIndex2>();
- add<BuildIndex>();
add<CS_10>();
add<PushBack>();
add<Create>();