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'

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 4.9.0, 4.4.3, 4.2.12
    • Affects Version/s: 4.4.2, 4.2.11
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v4.2
    • 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"
    • Query 2020-11-30
    • 8

      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.

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

              Created:
              Updated:
              Resolved: