Database lifecycle
The states a database moves through, from provisioning to deleted, with suspension, the deletion grace period and restoring.
A database is always in exactly one state. The state says whether applications can use it and which actions are allowed.
States
| State | Meaning | Applications |
|---|---|---|
provisioning | Being created on a cluster | Cannot connect yet |
ready | Created and confirmed by its cluster | Read and write |
failed | Could not be created | Cannot connect |
suspended | Read-only until resumed | Read only |
pending_deletion | Deleted; access is blocked and it can still be restored | Cannot connect |
deleting | Past its grace period; removed, its backups kept, then purged | Cannot connect |
deleted | Gone | — |
A database in the deleted state is no longer returned by the dashboard or the management API: it reads as not found.
provisioning ──► ready ◄──► suspended
│ │ │
▼ └─────┬──────┘
failed ──────────────►▼
pending_deletion ──► deleting ──► deleted
│
└── restore ──► ready or suspendedEvery transition is carried out by an operation, and a database runs one of them at a time. A request made while another is in progress is refused; wait for it to finish.
Provisioning
A new database is provisioning while it is placed on a cluster in its region, created there and configured. It becomes ready only after the cluster has been read back and found to hold the database with the access and limits that were asked for. Connection details are available from then on, not before.
If creation fails, the database becomes failed and its page says why. Choose Retry to run it again: every step is safe to repeat, so the retry continues where the failure stopped. A failed database can also be deleted.
Readiness
A state says what was asked for. Readiness says whether the cluster is known to enforce it. The management API returns it as the database's readiness field.
| Readiness | Meaning |
|---|---|
ready | The database is ready and its cluster enforces its latest configuration |
read_only | The database is suspended and its cluster enforces that |
converging | The cluster has not yet confirmed the latest configuration, and an operation is applying it |
stalled | The cluster has not confirmed the latest configuration and the operation applying it failed. Retry it |
unavailable | The database is failed, being deleted or deleted |
Suspending and resuming
Suspending a ready database makes it read-only: clients can still read documents, and every write is refused. Its keys, backups and addresses are untouched.
Resuming a suspended database lets clients write again.
Both are operations, so the state changes when the cluster has confirmed the change, not at the moment you ask.
Deleting
Deleting is deliberately slow to become final. In the dashboard you confirm by typing the database's name. A ready, suspended or failed database can be deleted.
A deletion goes through phases. The management API reports the current one as deletion.phase.
| Phase | State | What is happening | Restorable |
|---|---|---|---|
blocking | pending_deletion | Access is being blocked in the cluster. Clients may still connect for a moment | Once blocked |
grace | pending_deletion | Access is blocked and the data is intact | Yes, until restorableUntil |
restoring | pending_deletion | A restore cancelled the deletion and is reopening access | — |
removing | pending_deletion or deleting | The grace period is over. Keys are revoked; then the cluster removes the database | No |
purging | deleting | The cluster removed the database. What it still retains of it is being purged | No |
held | deleting | Removed; the cluster keeps its backups until heldUntil, then purges it | No |
Three things are worth knowing:
- The grace period starts when access is confirmed blocked, not when you ask. Until then no deadline is running. If blocking fails, clients can still connect and nothing is counting down: restore the database or retry the deletion.
- The deadline is shown. The database's page and
deletion.restorableUntilgive the time until which it can be restored. Read it rather than assuming a length. - A final backup is taken once access is blocked, so the last writes before the deletion are in a backup.
After the grace period the database's keys are revoked. From then on it cannot be restored by you.
Held for its backups
Backups are never deleted early. Once its keys are revoked and no backup of it is running, a deleted database is removed from its cluster: it serves nothing from then on. Its cluster keeps its backups, with the phase held, until the last of them, the daily ones included, reaches the end of its retention: about thirty days after its grace period ended. Then the cluster purges what it still retains of it, what its backups' copies left in the backup region is removed, and the deletion is complete. See backups.
A database in this phase does not count towards a plan's maximum number of databases, but it does keep its organization from being deleted.
Restoring a deleted database
While a database is pending_deletion and its grace period has not run out, choose Restore database. The deletion is cancelled, access is reopened, and the database returns to the state it had before: ready or suspended (or failed, if it had never been created successfully). Its data, keys and addresses are as they were.
A restore is refused in two cases:
- The deletion is still blocking access. Try again in a moment.
- The grace period is over.
If a restore fails, it can be run again. A database whose restore cannot succeed can still be deleted.
Once the grace period is over, you can no longer restore the database or its backups yourself. While its backups are still held, the service's operators can restore one into a new database on request. See backups.