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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Shell
    • Labels:
      None
    • Operating System:
      ALL
    • Case:

      Description

      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():

      146
       DB.prototype.upgradeCheck = function(obj, checkDocs) {
      147
              var self = this;
      148
              // parse args if there are any
      149
              if (obj) {
      150
                  // check collection if a collection is passed
      151
                  if (obj["collection"]) {
      152
                      // make sure a string was passed in for the collection
      153
                      if (typeof obj["collection"] !== "string") {
      154
                          throw Error("The collection field must contain a string");
      155
                      } else {
      156
                          print("Checking collection '" + self.getName() + '.' + obj["collection"] +
      157
                                "' for 2.6 upgrade compatibility");
      158
                          if (collUpgradeCheck(self.getCollection(obj["collection"]))) {
      159
                              print("Everything in '" + self.getName() + '.' + obj["collection"] +
      160
                                    "' is ready for the upgrade!");
      161
                              return true;
      162
                          }
      163
                          print("To fix the problems above please consult " +
      164
                                "http://dochub.mongodb.org/core/upgrade_checker_help");
      165
                          return false;
      166
                      }
      167
                  } else {
      168
                      throw Error(
      169
                          "When providing an argument to upgradeCheck, it must be of the form " +
      170
                          "{collection: <collectionNameString>}. Otherwise, it will check every " +
      171
                          "collection in the database. If you would like to check all databases, " +
      172
                          "run db.upgradeCheckAllDBs() from the admin database.");
      173
                  }
      174
              }
      175
      		<...>
      

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

        Attachments

          Activity

            People

            Assignee:
            backlog-server-platform Backlog - Platform Team
            Reporter:
            dmitry.ryabtsev Dmitry Ryabtsev
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: