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

collMod with validator omits default validationAction and validationLevel

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: Catalog, Replication
    • None
    • Fully Compatible
    • ALL
    • 99

      Before SERVER-52538, when you add a document validator to a collection with the "collMod" command, the default validationAction/Level are explicitly included in the collection's catalog entry. They appear in listCollections:

      > db.runCommand({collMod: "collection", validator: ...})
      {ok: 1}
      > db.getCollectionInfos()
      [
        {
          "name" : "foo",
          "type" : "collection",
          "options" : {
            "validator" : ...,
            "validationLevel" : "strict",
            "validationAction" : "error"
          }
      ]
      

      Oddly, if you create a collection with a validator using the "create" command, the default validation action/level are OMITTED from the catalog entry. This difference is probably unintentional but we should preserve it.

      After SERVER-52538's second commit, I accidentally changed this behavior, and collMod would OMIT validation action/level from the catalog entry if the user didn't pass values for them. concurrency_replication_multiversion and other suites started failing due to the inconsistency between old and new mongods' behavior.

      It's possible I introduced an inconsistency between collMod's behavior on primaries and secondaries, but I didn't investigate. Probably not, since we only saw failures in the multiversion suites.

      To fix this, I'll restore collMod's quirk: the default validation action/level are explicitly added to the catalog entry even when the user doesn't pass them.

            Assignee:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Reporter:
            jesse@mongodb.com A. Jesse Jiryu Davis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: