Does Cosmos DB provide an automatic rollback mechanism when a schema validation rule changes during a transaction?
0 reputation · 21 Feb 2025, 08:50 UTC
Goal
Determine whether Cosmos DB can automatically revert writes that succeed before a schema validation rule change but become invalid after the change, without requiring application‑level compensation.
The container‑level JSON schema validation is enforced at write time, and while TransactionalBatch provides atomicity across documents, a schema modification occurring mid‑transaction can leave the container in an inconsistent state if the service does not roll back the already‑applied writes.
- Does Cosmos DB automatically roll back previously accepted writes when a schema validation rule changes during the same transaction?
- If not, what patterns are recommended to achieve safe rollback or compensation?
- Are there any service‑side flags or API versions that enable schema‑change‑aware transactional rollback?