Guarantees
What the server promises about writes and reads, and what it deliberately does not promise.
This page states what an application can rely on when it talks to mimicd,
and where the limits are. It summarizes the promises that matter to
application code; how they are implemented and what a deployment must provide
for them to hold is covered in the Self-hosting
documentation.
What you can rely on
An acknowledged write is not lost. Once a transaction's outcome says it committed, the transaction survives the crash of any server process. The server answers a transaction only after it committed in PostgreSQL, so it is as durable as the database the deployment keeps it in.
A retried transaction is evaluated at most once. A client that lost an answer sends the same transaction id and request again and is told the original outcome. The server answers ids from its record for at least 30 days.
A document has one writer. Each document is served by one server process at a time, and its history is one order of committed changes, which every session receives in that order.
Reads show only durable state. A state, a change sent to a session or an HTTP read never reveals a state that a crash could take back.
Reads of a document are up to date. A read of one document reflects every write that was answered before the read was sent.
A client never drifts silently. Every change and state carries a hash of the document's content, which the client checks against its own copy.
A migration activates only when every document passes. A schema migration becomes active only after it was checked against every document of the collection, and no write can make a checked document fail before activation.
Schema validation is how the server works rather than one of these promises:
it checks the result of every transaction against the collection's schema
before it commits, and rejects a transaction whose result does not fit as
validation_failed. See Schemas.
What is not promised
Availability while a process fails over. When the process serving a
document fails, another process takes the document over; requests and
sessions that arrive in the meantime are answered unavailable, and clients
and the SDK send them again with backoff. A process that is stopped cleanly
hands its documents over first.
Transactions across documents. Documents are independent. There is no snapshot or transaction that spans two documents.
Listings as snapshots. A collection listing reads the documents as it goes: a document created or deleted while it runs may or may not appear. A document read by id is always current.
Timing an application can observe
| Event | When |
|---|---|
| A revoked key or grant, or a disabled user, stops working | Within seconds; at most 10 seconds by default |
| A quiet session lets its document leave memory | After 60 seconds without changes |
| A committed transaction id is answered on a retry | For the retry horizon, at least 30 days |
| A document token expires | At its exp, at most 24 hours after it was issued |
These are the server's defaults; an operator can change some of them.
What this means for your code
- Treat an edit as saved when the client no longer has it pending
(
hasPendingChanges()isfalse), not when the user made it. - Do not build your own retry around a transaction with a new id. Let the client or the SDK send it again with the same id.
- After creating a document, read it by id rather than looking for it in a listing.
- Keep things that must change together in one document.