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

StateMeaningApplications
provisioningBeing created on a clusterCannot connect yet
readyCreated and confirmed by its clusterRead and write
failedCould not be createdCannot connect
suspendedRead-only until resumedRead only
pending_deletionDeleted; access is blocked and it can still be restoredCannot connect
deletingPast its grace period; removed, its backups kept, then purgedCannot connect
deletedGone—

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 suspended

Every 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.

ReadinessMeaning
readyThe database is ready and its cluster enforces its latest configuration
read_onlyThe database is suspended and its cluster enforces that
convergingThe cluster has not yet confirmed the latest configuration, and an operation is applying it
stalledThe cluster has not confirmed the latest configuration and the operation applying it failed. Retry it
unavailableThe 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.

PhaseStateWhat is happeningRestorable
blockingpending_deletionAccess is being blocked in the cluster. Clients may still connect for a momentOnce blocked
gracepending_deletionAccess is blocked and the data is intactYes, until restorableUntil
restoringpending_deletionA restore cancelled the deletion and is reopening access—
removingpending_deletion or deletingThe grace period is over. Keys are revoked; then the cluster removes the databaseNo
purgingdeletingThe cluster removed the database. What it still retains of it is being purgedNo
helddeletingRemoved; the cluster keeps its backups until heldUntil, then purges itNo

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.restorableUntil give 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.