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

Fix use of 'onRollback' callback for collection validator options in 'collection_impl.cpp'

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: 4.4.2, 4.2.11
    • Fix Version/s: 4.9.0, 4.4.3, 4.2.12
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.2
    • Steps To Reproduce:
      Hide

      const encryptSchema = {
          $jsonSchema: {properties: {_id: {encrypt: {}}}}
      };
      const collName = "repro";
      db.createCollection(collName, {validator: encryptSchema, validationAction: "error"});
      assert.commandFailedWithCode(db.runCommand({collMod: collName, validationAction: "warn"}),
                                   ErrorCodes.QueryFeatureNotAllowed);
      print(tojson(db.runCommand({validate: collName, full: true})));
      

      The above script will produce the following error:
      "stored value for validation action does not match cached value: error != warn"

      Show
      const encryptSchema = { $jsonSchema: {properties: {_id: {encrypt: {}}}} }; const collName = "repro" ; db.createCollection(collName, {validator: encryptSchema, validationAction: "error" }); assert.commandFailedWithCode(db.runCommand({collMod: collName, validationAction: "warn" }), ErrorCodes.QueryFeatureNotAllowed); print(tojson(db.runCommand({validate: collName, full: true }))); The above script will produce the following error: "stored value for validation action does not match cached value: error != warn"
    • Sprint:
      Query 2020-11-30
    • Linked BF Score:
      8

      Description

      See 'steps to reproduce'. Basically, if the validationAction or validationLevel is set, but an error is thrown upon reparsing the validator, the value of CollectionImpl::_validationAction' or 'CollectionImpl::_validationLevel' never gets set back to its original value. This leads to the in memory value of validationAction/level not matching the on disk value.

        Attachments

          Activity

            People

            Assignee:
            mihai.andrei Mihai Andrei
            Reporter:
            mihai.andrei Mihai Andrei
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: