DR implementation: Cosmos DB
Tier: T0. Cosmos DB hosts the event stores, which are the source of truth for the platform (ADR-0007, ADR-0018). Three event stores are on the T0 path: incidents, tickets, and investigations.
This page is the home of event-store disaster recovery. It covers the account configuration, the recovery sequence (restore, validate ordering, replay), retention and snapshots, and the per-account gaps. It replaces the former event-store DR pages.
Current configuration (prd)
| Account | Role | Backup | Zone-redundant | Status |
|---|---|---|---|---|
cosno-bcinc | Incidents event store (T0) | Continuous, 30 days | Yes | Meets the guidelines |
cosno-bcinv-prd-chn-01 | Investigations event store (T0) | Periodic, every 240 minutes, 8-hour retention, geo backup storage | Yes | DR-01, HIGH |
cosno-bctkt-<env>-chn-01 | Tickets event store (T0) | Unknown | Unknown | DR-02, HIGH. Referenced in code, not found in the inventory |
cosno-bcrem | Remediation | Periodic, the same settings | Yes | DR-06 |
cosno-crbff | BFF store | Periodic, the same settings | Yes | DR-06 |
cosno-dprso-prd-chn-02 | Service store | Continuous, 30 days | No | DR-07 |
| Other accounts | Service stores | Continuous, 30 days | Yes | Meet the guidelines |
All accounts are single-region in Switzerland North. The Periodic accounts
use Periodic mode in gma, apa, and bta too.
Failure scenarios
| Scenario | Behaviour | Recovery | RTO and RPO |
|---|---|---|---|
| Node failure | Transparent | Automatic | RTO 0. RPO 0 |
| Zone loss, zone-redundant account | Transparent | Automatic | RTO 0. RPO 0 |
Zone loss, cosno-dprso | Possible unavailability until Microsoft recovers | Microsoft-managed | Until Microsoft recovers |
| Logical corruption or a bad writer | Invalid events or documents | Contain, then PITR to a new account, validate, replay (data recovery flow) | T0 objective of 4 hours or less. RPO is second-level on continuous, or up to 4 hours on Periodic |
| Container or database deleted | Missing data | Continuous: restore the deleted container or database in place. Periodic: support request | Minutes to hours |
| Account deleted | The store is gone | Continuous: restore the deleted account from the restorable list within retention. Periodic: support request | Hours |
| Throttling (429) | Write latency, and retries pile up | Raise the RU/s, or let autoscale act. Shed load with degraded-mode | Minutes |
| Switzerland North region outage | The event stores are unavailable | None in ION. The transactional platform waits for the region, an accepted risk in ADR-0017 | Not covered. See the region outage procedure |
What the targets claim
- RTO 0 and RPO 0 apply only to node and zone failures, for committed events on zone-redundant accounts.
- A logical failure on a T0 event store has the T0 objective of RTO 4 hours or less, at the PITR granularity of the account.
- A regional outage is not covered. The event-store targets in ADR-0018, RTO 30 minutes or less and RPO 0, belong to the planned multi-region posture, which is a proposal.
- Every value is an objective until a drill measures it.
Recovery procedures
The event-store sequence is stricter than a normal database restore, because the event log is the source of truth and every projection is rebuilt from it.
Find the restore point
Owner: Owning service team
Freeze the event-producing command handlers first, or make sure their commands are held in a durable queue.
Find the first bad write from the application logs and the change feed.
Choose a timestamp just before it, in UTC. Check that it is inside the
retention window with az cosmosdb restorable-database-account list.
Restore to a new account
Owner: Owning service team, approved by the incident commander
Run az cosmosdb restore with
--target-database-account-name <account>-rst-<yyyymmdd>, the source account,
and the restore timestamp.
Restore only the affected databases and containers if you can. The new
account does not inherit the networking, RBAC, or diagnostics settings, so
apply them from Terraform before any app connects.
Validate and replay
Owner: Owning service team
Run the event-store checks:
- the total event count, and the count per stream;
- a deterministic sample of event hashes;
- sequence continuity per aggregate: no gaps and no duplicate sequence numbers;
- the final event at the restore point: its identifier, timestamp, and aggregate sequence.
Then disable the normal projectors and rebuild the projections with isolated, idempotent replay workers against clean projection stores, using the replay procedures. Replay MUST NOT write to the event store.
Cut over
Owner: Owning service team, approved by the destructive restore approver
Reconcile the projector checkpoints, the pending commands, and the dead-lettered messages. Open the restored account read-only and validate business state and backlog. Then re-point the service configuration to the restored account, resume the consumers, and drain the Service Bus backlog at a controlled rate. Keep the damaged account read-only until the post-incident review closes. Making the restored account permanent is a separate failback change.
Rules
- Event-store accounts MUST use continuous backup with 30-day retention in
prd, as set by data protection. - Accounts MUST be zone-redundant in
gmaandprd. - The backup mode MUST be set explicitly in Terraform
(
backup { type = "Continuous", tier = "Continuous30Days" }). The live state showed that relying on the defaults hid the Periodic accounts. prdaccounts MUST haveprevent_destroyand aCanNotDeletelock.- A restore MUST target a new account. It MUST NOT overwrite the damaged account in place.
- Each bounded context MUST have its own event-store account.
- Event stores MUST keep append-only events, per-aggregate sequence numbers, and session consistency, and MUST NOT use multi-region writes.
- Services MUST reach the event store with managed identity and data-plane roles, not shared keys.
- Every projector MUST be idempotent and safe to replay.
- Writes MUST NOT reopen until pending commands and dead-lettered messages are reconciled.
Retention, archival, and snapshots
| Capability | Target | Status |
|---|---|---|
| Hot retention | Six months of queryable events (DATA-1) | Not enforced. Events stay in the hot store indefinitely |
| Cold retention | One year of replay-capable events in Blob storage (DATA-1, DATA-2) | Not implemented. No archival workflow moves or verifies events |
| Snapshots | Optional speed-up for long streams (DATA-3) | Designed, not implemented. Replay from the stream is the only recovery mechanism |
- PITR retention is a recovery control. It MUST NOT be treated as the cold-retention target.
- Recovery MUST NOT depend on snapshots until snapshot creation, versioning, integrity checks, and fallback to stream replay are implemented.
- Snapshots SHOULD be re-evaluated for an aggregate when its stream length causes a measured reconstruction problem.
The design is in archival and snapshots.
Gaps
| ID | Severity | Gap | Owner |
|---|---|---|---|
| DR-01 | HIGH | Investigations event store on Periodic backup | Investigations team, CPE |
| DR-02 | HIGH | Tickets event store not found in the inventory | Tickets team, CPE |
| DR-06 | MEDIUM | cosno-bcrem and cosno-crbff on Periodic backup | Owning service teams |
| DR-07 | MEDIUM | cosno-dprso not zone-redundant | Owning service team |
Validation and drills
- Twice a year in
gma: restore an event store to a new account, validate it, and replay one projection. - Record the drill evidence: the selected restore point, the backup lag, the restore duration, the replay throughput, the projection catch-up time, the validation results, and the final RTO and RPO. A walkthrough without a real restore does not validate PITR.
- The event-store drill has been run once. Its results are not yet recorded here (RT-04).
- Plan review: run a Resource Graph check on
backupPolicy.typeand on the zone redundancy of every location.