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

    • Bug
    • Status: Closed
    • Critical - P2
    • Resolution: Fixed
    • 4.4.2, 4.2.11
    • 4.9.0, 4.4.3, 4.2.12
    • 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

    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

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

            Dates

              Created:
              Updated:
              Resolved: