Constraint validation adoption and existing-document guarantees
Parent: mongodb-schema-design · Published reference · snapshot 2026-10-29
↓ Facts as markdownall context files
Source-anchored research for Constraint validation adoption and existing-document guarantees. Run status: COMPLETED.
These notes link each claim to its source. Some citations identify archived research reports that are no longer hosted on this site. A published reference means the content is available; it does not certify independent review or accuracy.Read the editorial policy and follow the sources before relying on a claim.
Problems, failure modes and limitations
- Constraint requires validationAction 'error' or 'errorAndLog'; a warning-only action cannot provide its enforcement guarantee. (medium confidence) (verified as of 2026-10-14) [source]
- Compass issue COMPASS-10969 describes interrupted or failed upgrades leaving prepareConstraintValidationLevel:true indefinitely while validationLevel still reads strict. Validator edits remain locked; the proposed warning suggests lowering the validation level to strict or clearing the prepared flag through collMod. (low confidence) (verified as of 2026-08-14) [source]
- Constraint requires validationAction "error" or "errorAndLog". The validator cannot change while constraint is active or in the same collMod that enables constraint; revise rules by downgrading to strict, changing the validator, and preparing/upgrading again. (high confidence) (verified as of 2026-10-14) [source]
Comparisons and alternatives
- VisuaLeaf's author reports testing MongoDB 9.0.2 with FCV 9.0 on local Docker, viewing the constraint level in Schema Manager, and observing rejection of a validator edit while constraint was active. The article explicitly limits its results to local command tests rather than full compatibility certification. (low confidence) (verified as of 2026-10-09) [source]
Facts and statements
- MongoDB 9.0 introduces validationLevel: "constraint", which enforces inserts and updates and guarantees that all documents in the collection satisfy its validator, including documents stored before the level was enabled. (high confidence) (verified as of 2026-10-14) [source]
- Strict validation checks all inserts and updates but does not certify untouched existing documents. Moderate validation also exempts updates to existing invalid documents; neither level provides constraint's collection-wide guarantee. (high confidence) (verified as of 2026-10-14) [source]
- For an existing collection, MongoDB's documented adoption sequence is to set strict validation, run collMod with prepareConstraintValidationLevel: true, then run a separate collMod setting validationLevel: "constraint". Preparation blocks bypassDocumentValidation and changes to the validator. (high confidence) (verified as of 2026-10-14) [source]
- The upgrade to constraint scans all existing documents and fails collMod if any violate the validator. Operators must repair violations before retrying, and the scan can be computationally expensive on large collections. (medium confidence) (verified as of 2026-10-14) [source]
- A newly created collection can use constraint immediately without the strict/preparation sequence required for an existing collection. A VisuaLeaf author reports successful creation with this setting on MongoDB 9.0.2. (medium confidence) (verified as of 2026-10-09) [source]
- MongoDB rejects validator changes while constraint is active and disallows changing the validator in the collMod that upgrades to constraint. The documented change procedure is to downgrade to strict, edit the validator, then prepare and upgrade again. (medium confidence) (verified as of 2026-10-14) [source]
- COMPASS-10969 documents a blank validation-level dropdown and incorrectly offered rule editing for constraint collections, and records a fix version of 1.49.15. This is a tooling adoption issue, not evidence that the server accepts invalid writes. (low confidence) (verified as of 2026-08-14) [source]
- NoSQLBooster's 11.1.7 release-note entry documents constraint in Add/Modify Validator templates and completion, including the action restriction and prohibition on changing the validator in the same collMod. This is evidence of client tooling support, not a measurement of deployment adoption. (low confidence) (verified as of 2026-10-27) [source]
- SERVER-127372 tracks preventing shard-key updates from hiding invalid documents during the constraint upgrade and records a fix in 9.0.0-rc0. The ticket supports a concurrency verification concern but does not describe a production incident. (low confidence) (verified as of 2026-06-15) [source]
Children
- No children recorded.