summaryrefslogtreecommitdiff
path: root/src/mongo/db/db.cpp
diff options
context:
space:
mode:
authorJason Rassi <rassi@10gen.com>2014-03-06 15:33:46 -0500
committerJason Rassi <rassi@10gen.com>2014-03-07 13:20:40 -0500
commitae451ca13f2803b315a136a0efebcc123129f069 (patch)
tree618c3689c32ed02581f13346a305ca923e22bc0b /src/mongo/db/db.cpp
parent7736ee885b28295a60ba39f9f6d7d59beb35b34f (diff)
downloadmongo-ae451ca13f2803b315a136a0efebcc123129f069.tar.gz
SERVER-12914 initAndListen call dbexit if invalid IndexSpec found
Diffstat (limited to 'src/mongo/db/db.cpp')
-rw-r--r--src/mongo/db/db.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index ec337c89885..b66cd60d913 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -361,12 +361,12 @@ namespace mongo {
}
}
else {
- if (h->versionMinor == PDFILE_VERSION_MINOR_22_AND_OLDER) {
- const string systemIndexes = cc().database()->name + ".system.indexes";
- shared_ptr<Cursor> cursor(theDataFileMgr.findAll(systemIndexes));
- for ( ; cursor && cursor->ok(); cursor->advance()) {
- const BSONObj index = cursor->current();
- const BSONObj key = index.getObjectField("key");
+ const string systemIndexes = cc().database()->name + ".system.indexes";
+ shared_ptr<Cursor> cursor(theDataFileMgr.findAll(systemIndexes));
+ for ( ; cursor && cursor->ok(); cursor->advance()) {
+ const BSONObj index = cursor->current();
+ const BSONObj key = index.getObjectField("key");
+ if (h->versionMinor == PDFILE_VERSION_MINOR_22_AND_OLDER) {
const string plugin = IndexPlugin::findPluginName(key);
if (IndexPlugin::existedBefore24(plugin))
continue;
@@ -377,6 +377,21 @@ namespace mongo {
<< "http://dochub.mongodb.org/core/upgrade-2.4"
<< startupWarningsLog;
}
+ else {
+ verify(h->versionMinor == PDFILE_VERSION_MINOR_24_AND_NEWER);
+ try {
+ IndexSpec(key, index, IndexSpec::RulesFor24);
+ }
+ catch (const DBException& e) {
+ error() << "Encountered an unrecognized index spec: " << index << endl;
+ error() << "Reason this index spec could not be loaded: \"" << e.what()
+ << "\"" << endl;
+ error() << "The index cannot be used with this version of MongoDB; "
+ << "exiting..." << endl;
+ cc().shutdown();
+ dbexit(EXIT_UNCAUGHT);
+ }
+ }
}
Database::closeDatabase( dbName.c_str(), dbpath );
}