summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2017-05-24 12:34:46 -0400
committerDianna Hohensee <dianna.hohensee@10gen.com>2017-05-25 16:35:05 -0400
commit5b3d2570abe554f1eb7602ffdcd0ee811def9029 (patch)
tree2c5081a40625f065dc55d0caa81ad78bf10fb1c0
parent0b5217dfddf7f5f3253a724fb7debbaa5f3b3e1f (diff)
downloadmongo-5b3d2570abe554f1eb7602ffdcd0ee811def9029.tar.gz
SERVER-29349 delete shell/upgrade_check.js, which was relevant for v2.6 upgrade and now no longer used
-rw-r--r--src/mongo/scripting/engine.cpp2
-rw-r--r--src/mongo/scripting/mozjs/object.cpp28
-rw-r--r--src/mongo/scripting/mozjs/object.h3
-rw-r--r--src/mongo/shell/SConscript1
-rw-r--r--src/mongo/shell/upgrade_check.js211
5 files changed, 3 insertions, 242 deletions
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp
index cb6043d61aa..987c3136a47 100644
--- a/src/mongo/scripting/engine.cpp
+++ b/src/mongo/scripting/engine.cpp
@@ -288,7 +288,6 @@ extern const JSFile explainable;
extern const JSFile mongo;
extern const JSFile mr;
extern const JSFile query;
-extern const JSFile upgrade_check;
extern const JSFile utils;
extern const JSFile utils_sh;
extern const JSFile utils_auth;
@@ -310,7 +309,6 @@ void Scope::execCoreFiles() {
execSetup(JSFiles::crud_api);
execSetup(JSFiles::explain_query);
execSetup(JSFiles::explainable);
- execSetup(JSFiles::upgrade_check);
}
namespace {
diff --git a/src/mongo/scripting/mozjs/object.cpp b/src/mongo/scripting/mozjs/object.cpp
index 0bd33b3d72d..1b1cb62510f 100644
--- a/src/mongo/scripting/mozjs/object.cpp
+++ b/src/mongo/scripting/mozjs/object.cpp
@@ -38,8 +38,8 @@
namespace mongo {
namespace mozjs {
-const JSFunctionSpec ObjectInfo::methods[3] = {
- MONGO_ATTACH_JS_FUNCTION(bsonsize), MONGO_ATTACH_JS_FUNCTION(invalidForStorage), JS_FS_END,
+const JSFunctionSpec ObjectInfo::methods[2] = {
+ MONGO_ATTACH_JS_FUNCTION(bsonsize), JS_FS_END,
};
const char* const ObjectInfo::className = "Object";
@@ -59,29 +59,5 @@ void ObjectInfo::Functions::bsonsize::call(JSContext* cx, JS::CallArgs args) {
args.rval().setInt32(ValueWriter(cx, args.get(0)).toBSON().objsize());
}
-void ObjectInfo::Functions::invalidForStorage::call(JSContext* cx, JS::CallArgs args) {
- if (args.length() != 1)
- uasserted(ErrorCodes::BadValue, "invalidForStorage needs 1 argument");
-
- if (args.get(0).isNull()) {
- args.rval().setNull();
- return;
- }
-
- if (!args.get(0).isObject())
- uasserted(ErrorCodes::BadValue, "argument to invalidForStorage has to be an object");
-
- Status validForStorage = ValueWriter(cx, args.get(0)).toBSON().storageValid(true);
- if (validForStorage.isOK()) {
- args.rval().setNull();
- return;
- }
-
- std::string errmsg = str::stream() << validForStorage.codeString() << ": "
- << validForStorage.reason();
-
- ValueReader(cx, args.rval()).fromStringData(errmsg);
-}
-
} // namespace mozjs
} // namespace mongo
diff --git a/src/mongo/scripting/mozjs/object.h b/src/mongo/scripting/mozjs/object.h
index f5e921155c2..2e7841f939a 100644
--- a/src/mongo/scripting/mozjs/object.h
+++ b/src/mongo/scripting/mozjs/object.h
@@ -42,10 +42,9 @@ namespace mozjs {
struct ObjectInfo : public BaseInfo {
struct Functions {
MONGO_DECLARE_JS_FUNCTION(bsonsize);
- MONGO_DECLARE_JS_FUNCTION(invalidForStorage);
};
- static const JSFunctionSpec methods[3];
+ static const JSFunctionSpec methods[2];
static const char* const className;
diff --git a/src/mongo/shell/SConscript b/src/mongo/shell/SConscript
index 73dee5eea45..c4f33385344 100644
--- a/src/mongo/shell/SConscript
+++ b/src/mongo/shell/SConscript
@@ -26,7 +26,6 @@ js_header = env.JSHeader(
"mr.js",
"query.js",
"types.js",
- "upgrade_check.js",
"utils.js",
"utils_sh.js",
"utils_auth.js",
diff --git a/src/mongo/shell/upgrade_check.js b/src/mongo/shell/upgrade_check.js
deleted file mode 100644
index 0bd61972ffc..00000000000
--- a/src/mongo/shell/upgrade_check.js
+++ /dev/null
@@ -1,211 +0,0 @@
-(function() {
- "use strict";
-
- /**
- * Check a document
- */
- var documentUpgradeCheck = function(indexes, doc) {
- var goodSoFar = true;
- var invalidForStorage = Object.invalidForStorage(doc);
- if (invalidForStorage) {
- print("Document Error: document is no longer valid in 2.6 because " +
- invalidForStorage + ": " + tojsononeline(doc));
- goodSoFar = false;
- }
- indexes.forEach(function(idx) {
- if (isKeyTooLarge(idx, doc)) {
- print("Document Error: key for index " + tojsononeline(idx) +
- " too long for document: " + tojsononeline(doc));
- goodSoFar = false;
- }
- });
- return goodSoFar;
- };
-
- var indexUpgradeCheck = function(index) {
- var goodSoFar = true;
- var indexValid = validateIndexKey(index.key);
- if (!indexValid.ok) {
- print("Index Error: invalid index spec for index '" + index.name + "': " +
- tojsononeline(index.key));
- goodSoFar = false;
- }
- return goodSoFar;
- };
-
- var collUpgradeCheck = function(collObj, checkDocs) {
- var fullName = collObj.getFullName();
- var collName = collObj.getName();
- var dbName = collObj.getDB().getName();
- print("\nChecking collection " + fullName + " (db:" + dbName + " coll:" + collName + ")");
- var dbObj = collObj.getDB();
- var goodSoFar = true;
-
- // check for _id index if and only if it should be present
- // no $, not oplog, not system, not config db
- var checkIdIdx = true;
- if (dbName == "config") {
- checkIdIdx = false;
- } else if (dbName == "local") {
- if (collName == "oplog.rs" || collName == "oplog.$main" || collName == "startup_log" ||
- collName == "me") {
- checkIdIdx = false;
- }
- }
-
- if (collName.indexOf('$') !== -1 || collName.indexOf("system.") === 0) {
- checkIdIdx = false;
- }
- var indexes = collObj.getIndexes();
- var foundIdIndex = false;
-
- // run index level checks on each index on the collection
- indexes.forEach(function(index) {
-
- if (index.name == "_id_") {
- foundIdIndex = true;
- }
-
- if (!indexUpgradeCheck(index)) {
- goodSoFar = false;
- } else {
- // add its key to the list of index keys to check documents against
- if (index["v"] !== 1) {
- print("Warning: upgradeCheck only supports V1 indexes. Skipping index: " +
- tojsononeline(index));
- } else {
- indexes.push(index);
- }
- }
- });
-
- // If we need to validate the _id_ index, see if we found it.
- if (checkIdIdx && !foundIdIndex) {
- print("Collection Error: lack of _id index on collection: " + fullName);
- goodSoFar = false;
- }
- // do not validate the documents in system collections
- if (collName.indexOf("system.") === 0) {
- checkDocs = false;
- }
- // do not validate the documents in config dbs
- if (dbName == "config") {
- checkDocs = false;
- }
- // do not validate docs in local db for some collections
- else if (dbName === "local") {
- if (collName == "oplog.rs" || // skip document validation for oplogs
- collName == "oplog.$main" ||
- collName == "replset.minvalid" // skip document validation for minvalid coll
- ) {
- checkDocs = false;
- }
- }
-
- if (checkDocs) {
- var lastAlertTime = Date.now();
- var alertInterval = 10 * 1000; // 10 seconds
- var numDocs = 0;
- // run document level checks on each document in the collection
- var theColl = dbObj.getSiblingDB(dbName).getCollection(collName);
- theColl.find()
- .addOption(DBQuery.Option.noTimeout)
- .sort({$natural: 1})
- .forEach(function(doc) {
- numDocs++;
-
- if (!documentUpgradeCheck(indexes, doc)) {
- goodSoFar = false;
- lastAlertTime = Date.now();
- }
- var nowTime = Date.now();
- if (nowTime - lastAlertTime > alertInterval) {
- print(numDocs + " documents processed");
- lastAlertTime = nowTime;
- }
- });
- }
-
- return goodSoFar;
- };
-
- var dbUpgradeCheck = function(dbObj, checkDocs) {
- print("\nChecking database " + dbObj.getName());
- var goodSoFar = true;
-
- // run collection level checks on each collection in the db
- dbObj.getCollectionNames().forEach(function(collName) {
- if (!collUpgradeCheck(dbObj.getCollection(collName), checkDocs)) {
- goodSoFar = false;
- }
- });
-
- return goodSoFar;
- };
-
- DB.prototype.upgradeCheck = function(obj, checkDocs) {
- var self = this;
- // parse args if there are any
- if (obj) {
- // check collection if a collection is passed
- if (obj["collection"]) {
- // make sure a string was passed in for the collection
- if (typeof obj["collection"] !== "string") {
- throw Error("The collection field must contain a string");
- } else {
- print("Checking collection '" + self.getName() + '.' + obj["collection"] +
- "' for 2.6 upgrade compatibility");
- if (collUpgradeCheck(self.getCollection(obj["collection"]))) {
- print("Everything in '" + self.getName() + '.' + obj["collection"] +
- "' is ready for the upgrade!");
- return true;
- }
- print("To fix the problems above please consult " +
- "http://dochub.mongodb.org/core/upgrade_checker_help");
- return false;
- }
- } else {
- throw Error(
- "When providing an argument to upgradeCheck, it must be of the form " +
- "{collection: <collectionNameString>}. Otherwise, it will check every " +
- "collection in the database. If you would like to check all databases, " +
- "run db.upgradeCheckAllDBs() from the admin database.");
- }
- }
-
- print("database '" + self.getName() + "' for 2.6 upgrade compatibility");
- if (dbUpgradeCheck(self, checkDocs)) {
- print("Everything in '" + self.getName() + "' is ready for the upgrade!");
- return true;
- }
- print("To fix the problems above please consult " +
- "http://dochub.mongodb.org/core/upgrade_checker_help");
- return false;
- };
-
- DB.prototype.upgradeCheckAllDBs = function(checkDocs) {
- var self = this;
- if (self.getName() !== "admin") {
- throw Error("db.upgradeCheckAllDBs() can only be run from the admin database");
- }
-
- var dbs = self.getMongo().getDBs();
- var goodSoFar = true;
-
- // run db level checks on each db
- dbs.databases.forEach(function(dbObj) {
- if (!dbUpgradeCheck(self.getSiblingDB(dbObj.name), checkDocs)) {
- goodSoFar = false;
- }
- });
-
- if (goodSoFar) {
- print("Everything is ready for the upgrade!");
- return true;
- }
- print("To fix the problems above please consult " +
- "http://dochub.mongodb.org/core/upgrade_checker_help");
- return false;
- };
-
-})();