Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-34609

The db.upgradeCheck() helper silently fails to validate the documents on a collection

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
      None
    • ALL

      I'm not sure if we still maintain these helpers but they often happen to become helpful in cases about Atlas migrations that are failing due to certain limits being violated on the source (e.g. index key size limit).

      Similar to db.upgradeCheckAllDBs(), db.upgradeCheck() has an extra option that enforces document check (checkDocs).

      Normally you'd need to call it as db.upgradeCheck(undefined, true); to execute the check on all of the documents in all collections in the database. For the scope of a single collection it would be:

      db.upgradeCheck({ collection: "<name>"}, true);
      

      However that does not enforces the document check. The reason is that we don't pass the checkDocs argument into collUpgradeCheck():

       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.");
                  }
              }
      		<...>
      

      It was tested that modifying the collUpgradeCheck() call in the line #158 in upgrade_check.js to have checkDocs fixes the issue.

            Assignee:
            backlog-server-platform DO NOT USE - Backlog - Platform Team
            Reporter:
            dmitry.ryabtsev@mongodb.com Dmitry Ryabtsev
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: