# Reliability
Source: https://sovaria.in/docs/reliability

Timeouts, retries and idempotency, how the platform recovers from a failed service, what each plan offers for availability, and how to diagnose an incident.

## Retries and idempotency

Networks fail. Retry **safe** requests (reads) freely and **writes** only with an idempotency key, so a write the server already did isn't done twice.

- The SDKs retry failed requests with backoff and give every write one `Idempotency-Key` from its first attempt, so a retried write is applied once.
- From your own HTTP client, send `Idempotency-Key: <unique id per operation>` on writes you may retry. Keys belong to the signed-in user or API key that sent them (not the exact token), so a retry after a token refresh still finds its key, and nobody else's request can claim or replay it. A retry while the first is still running gets `409 IDEMPOTENCY_IN_PROGRESS`: wait and retry with the same key. A `429` or `503` that carries `X-Sovaria-Refused: before-forward` was refused by the gateway before it reached any service (its rate limits, overload shedding, circuit breaker): nothing was done, so a write may be sent again after its `Retry-After`. A function call Forge refused because every sandbox was busy carries `X-Sovaria-Runner-Refused: before-start` (the function never started). A service's own `429` or `503`, or one your HTTP function returns, has no such mark and may come after part of the work.
- The server keeps a successful write's answer for an hour and returns it (with `X-Idempotency-Replayed: 1`) to a retry with the same key; the same key with a different body gets `409 IDEMPOTENCY_PAYLOAD_MISMATCH`. Writes the server refused (a `4xx`, or a `501`/`503` before any work) are not kept, so their retry runs again. A write whose outcome is unknown (the engine timed out, the connection dropped after the request was sent, or it failed with another `5xx`) may have been applied, and a successful write whose answer is over 256 KB was applied but can't be replayed, so its key stays taken for the same hour: a retry gets `409 IDEMPOTENCY_OUTCOME_UNKNOWN` instead of running it a second time. Check whether it happened (read the row, document or order) and, if not, send it again with a new key. Answers that carry credentials (sign-in tokens, a new API key, a client secret) are kept for two minutes only: long enough for retries.
- Honour `Retry-After` on `429` and `503`; back off exponentially otherwise.
- Function triggers retry failed runs and keep the ones that keep failing in a dead-letter queue ([Event triggers](https://sovaria.in/docs/function-triggers)); make handlers safe to run twice.

## Timeouts

| Where | Limit | Set it in |
|---|---|---|
| A SQL statement | Your statement timeout | [Pooling and timeouts](https://sovaria.in/docs/settings-pooling-and-timeouts) |
| A function run | The function's timeout, up to your plan's maximum | [Function memory, timeout and limits](https://sovaria.in/docs/functions-limits) |
| A workflow step's sleep | Plan maximum | [Durable workflows](https://sovaria.in/docs/function-workflows) |

## How the platform recovers

- **A service crashes:** it is restarted at once, and requests reach it again within seconds of it starting (the gateway re-checks a failed service after 2 seconds, then backs off up to 30 seconds while it stays down). Requests that arrive in between get `503` with a reason; the SDKs retry them.
- **A service stops answering but keeps running:** its health check fails three times in a row and it is restarted automatically, with time to finish the requests it is serving: within about two minutes for the API gateway (which runs as two copies, so the other one keeps serving) and about four for the other services. To avoid making an outage worse, the same service is restarted at most once every 15 minutes and four times a day, the platform's own cache and database are never restarted this way, and when several services fail at once (a shared cause) none is; our on-call is alerted in every case.
- **Deploys:** most services roll: a new copy starts next to the old one, and the old one keeps serving until the new one is healthy and has passed a smoke test, then finishes its in-flight requests and stops; a new copy that fails either check is removed. A few that must run as one copy (the platform's cache, the consensus store) restart in place, which interrupts them for a few seconds.
- **Your project's database stalls:** only that project's requests wait or get `503`; other projects aren't affected, and requests flow again as soon as the database answers.

## Availability by plan

|  | Free | Pro | Ultra | Team | Enterprise |
|---|---|---|---|---|---|
| Uptime target | Best effort | Best effort | Best effort | Best effort | Best effort |
| High-availability failover (when multi-server redundancy is available) | — | — | — | ✓ | ✓ |
| Read replicas (billed by the hour) | — | Addon | Addon | Addon | Addon |
| Isolated compute cluster (set up on request) | — | — | — | ✓ | ✓ |
| Days without requests before the database is paused (0 = never); the next request resumes it | 7 days | Never | Never | Never | Never |
| Support channel | Community | Email | Priority | Dedicated | Tam |

Free databases pause after 7 days without requests and start again on the next one, which then takes a few seconds. Paid plans don't pause unless you turn idle pause on.

Database servers nobody connects to also **sleep**: staging, branch and preview databases after 3 days, Free projects after 14; paid production databases never sleep. The next request or connection wakes the server in a few seconds — see [Database: connection, compute, disk and backups](https://sovaria.in/docs/settings-database).

## When something goes wrong

1. **Read the error** — The status code and `detail.code` usually say what happened — see the table in [HTTP API](https://sovaria.in/docs/http-api).
2. **Find the request** — Search the `X-Request-ID` or `trace_id` in Logs & Audit to see where it stopped.
3. **Check what changed** — A recent deploy, migration or policy change? [Version history: see, undo and restore changes](https://sovaria.in/docs/version-history) shows it and can roll it back.
4. **Check limits** — Plan & usage shows whether a quota ran out.
5. **Contact support** — Include the trace id, the time and your project URL.
