[SERVER-52975] Fix use of 'onRollback' callback for collection validator options in 'collection_impl.cpp' Created: 20/Nov/20  Updated: 29/Oct/23  Resolved: 25/Nov/20

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4.2, 4.2.11
Fix Version/s: 4.9.0, 4.4.3, 4.2.12

Type: Bug Priority: Critical - P2
Reporter: Mihai Andrei Assignee: Mihai Andrei
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2
Steps To Reproduce:

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
Participants:
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.



 Comments   
Comment by Githook User [ 30/Nov/20 ]

Author:

{'name': 'Mihai Andrei', 'email': 'mihai.andrei@10gen.com', 'username': 'mtandrei'}

Message: SERVER-52975 Fix use of 'onRollback' callback for collection validator options in 'collection_impl.cpp'

(cherry picked from commit 459e61631a0f806962fe481aed80363d2d438a04)
Branch: v4.2
https://github.com/mongodb/mongo/commit/644705e5755227ce13ca7fdee405003c4dd2cebb

Comment by Githook User [ 25/Nov/20 ]

Author:

{'name': 'Mihai Andrei', 'email': 'mihai.andrei@10gen.com', 'username': 'mtandrei'}

Message: SERVER-52975 Fix use of 'onRollback' callback for collection validator options in 'collection_impl.cpp'
Branch: v4.4
https://github.com/mongodb/mongo/commit/459e61631a0f806962fe481aed80363d2d438a04

Comment by Githook User [ 25/Nov/20 ]

Author:

{'name': 'Mihai Andrei', 'email': 'mihai.andrei@10gen.com', 'username': 'mtandrei'}

Message: SERVER-52975 Update doc_validation_encrypt_keywords.js to verify consistency of in-memory versus persisted state
Branch: master
https://github.com/mongodb/mongo/commit/67fb1e7c8d19c3eda1c8a9b439b232c0e501d363

Comment by David Storch [ 23/Nov/20 ]

mihai.andrei can you add a description so that there is context here?

Generated at Thu Feb 08 05:29:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.