[SERVER-53575] collMod with validator omits default validationAction and validationLevel Created: 05/Jan/21  Updated: 29/Oct/23  Resolved: 06/Jan/21

Status: Closed
Project: Core Server
Component/s: Catalog, Replication
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Problem/Incident
is caused by SERVER-52538 Update IDL definition for create command Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 99

 Description   

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.



 Comments   
Comment by Ian Whalen (Inactive) [ 07/Jan/21 ]

Author:

{'username': u'evrg-bot-webhook', 'name': u'A. Jesse Jiryu Davis', 'email': u'jesse@mongodb.com'}

Message:SERVER-53575 Include default validation action/level in catalog entry
Branch:master
https://github.com/mongodb/mongo/commit/f19b1f3ab4b5d8763250e9b2ab4c81f9e44f07c3

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