summaryrefslogtreecommitdiff
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
parent7736ee885b28295a60ba39f9f6d7d59beb35b34f (diff)
downloadmongo-ae451ca13f2803b315a136a0efebcc123129f069.tar.gz
SERVER-12914 initAndListen call dbexit if invalid IndexSpec found
-rw-r--r--src/mongo/db/db.cpp27
-rw-r--r--src/mongo/db/geo/s2index.cpp6
2 files changed, 24 insertions, 9 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 );
}
diff --git a/src/mongo/db/geo/s2index.cpp b/src/mongo/db/geo/s2index.cpp
index cfc1623022f..412d425f2f8 100644
--- a/src/mongo/db/geo/s2index.cpp
+++ b/src/mongo/db/geo/s2index.cpp
@@ -366,7 +366,7 @@ namespace mongo {
uassert(16689, "finestIndexedLevel must be >= coarsestIndexedLevel",
params.finestIndexedLevel >= params.coarsestIndexedLevel);
massert(17289,
- str::stream() << "unsupported geo index version { 2dsphereIndexVersion : "
+ str::stream() << "unsupported geo index version { "
<< spec->info["2dsphereIndexVersion"]
<< " }, only support versions: [1]",
configValueWithDefault(spec, "2dsphereIndexVersion", 1) == 1);
@@ -396,8 +396,8 @@ namespace mongo {
virtual BSONObj adjustIndexSpec( const BSONObj& spec ) const {
BSONElement indexVersionElt = spec["2dsphereIndexVersion"];
uassert(17290,
- str::stream() << "unsupported geo index version { 2dsphereIndexVersion : "
- << indexVersionElt << " }, only support versions: [1]",
+ str::stream() << "unsupported geo index version { " << indexVersionElt
+ << " }, only support versions: [1]",
indexVersionElt.eoo() || indexVersionElt.numberInt() == 1);
return spec;
}