Consistency¶
Strict serializability, scoped to one FoundationDB transaction: transactions appear to run one at a time, in an order that respects real time. By default, a read sees every write that completed before it started.
gantt
title Illustrative time (ms)
accTitle: Write A returns before read B starts
accDescr: Time runs left to right. Write A ends at its response. Read B starts later, after a gap. B's default read sees A.
dateFormat x
axisFormat %Q
tickInterval 200millisecond
todayMarker off
Write A :a, 0, 300
Read B :done, b, 500, 800
A returns :vert, a_end, 300, 0ms
B starts :vert, b_start, 500, 0ms
B starts after A returned, so B's default read sees A.
All reads in a transaction share one snapshot. Its writes become visible together at commit. A conflicting write rejects the commit, and fdyno retries at a newer snapshot while the request's budget allows. Overlapping requests can serialize in either order; a read does not wait for writes in flight.
Transaction scope by API¶
| Request | Consistency boundary |
|---|---|
GetItem |
One read snapshot. An expired item is hidden. |
Query, Scan |
One snapshot per page. |
Batch |
One snapshot for all keys. |
PutItem, Update, Delete |
One transaction: condition, item, LSI entries, GSI change records, stream record. |
Transact |
One snapshot for all items. |
Transact |
One transaction for all actions and the token. |
Execute |
One transaction for all statements. |
Batch |
Not atomic. Usually one transaction; a batch too large for one commits in parts. |
Several pages of a Query or Scan |
A new snapshot per page. |
| GSI update | After the write's transaction; GSI reads are eventually consistent. |
| New GSI backfill | One transaction per page while CREATING; complete at ACTIVE. |
| Backup | Pages read at one pinned read version; ROLLING (consistent per item) if that version expires. |
| Restore | Batches with progress; the table is CREATING until its items and GSIs are built. |
LastEvaluatedKey is a position, not a saved snapshot. A multi-page scan can
see intervening writes, as in DynamoDB. Transactions
shows how the APIs are built.
For example, an ascending Query ends a page at sort key B. A writer
then inserts A and C in that partition. The next page starts after B:
its fresh snapshot can include C, but it does not go back for A.
ConsistentRead=true does not change that boundary.
For a known set of keys, use BatchGetItem for a single request snapshot. Use
TransactGetItems when you need the transaction API. A retry of unprocessed
keys starts a new snapshot. For the position checks, see the
range and pagination test.
Read modes¶
Every API read gets a fresh read version from FoundationDB, including reads
without ConsistentRead. Each BatchGetItem or Query page uses one version
per attempt. ConsistentRead still controls consumed capacity and which API
requests are valid. For example, a GSI query rejects ConsistentRead=true.
A write can start at a recent read version instead. The first attempt of a
PutItem, UpdateItem, DeleteItem, TransactWriteItems,
BatchWriteItem or write ExecuteTransaction can reuse the newest read
version that another request got. That version is at most 1 second old for
a write that reads no item, and at most 100 ms old for a write that reads
items. Its item reads are serializable, and each table's revision key gets
a read conflict. So the commit fails if an item or the table metadata
changed after that version, and fdyno retries at a new read version. Only
a checked commit answers from that version. An attempt that ends without
one (a failed condition, an error, no mutation to commit, or a
BatchWriteItem over the transaction size cap) runs again at a new read
version. A TransactWriteItems of only ConditionCheck actions always
gets a new read version.
The cached and risky read modes were removed. Unset DYNODB_EVENTUAL_READS
before upgrading. A blank value or grv starts; every other value refuses
startup. This does not affect pinned backup reads.
If FoundationDB cannot provide a fresh version, the request waits within its deadline. It does not fall back to an older snapshot.
States a transaction cannot show¶
| Anomaly | Why it cannot happen |
|---|---|
| Dirty read | Uncommitted writes are invisible. |
| Fractured read | A reader sees all or none of a committed multi-key write. |
| Lost update | The item is read in the same transaction as the write; a conflicting commit rejects this one, and fdyno retries while the budget allows. |
| Write skew | Read keys and ranges are conflict-checked. |
| Phantom | An insert into a range the transaction read conflicts with that read. |
Reads register keys and ranges with FoundationDB. In a transaction that commits, an overlapping write rejects the commit, and fdyno can retry it (below). fdyno adds no separate consistency algorithm. Conflict retries protect accepted changes, including increments, lists, sets and nested updates. Read-only requests that skip conflict registration never commit and still read one snapshot.
Which reads are conflict-checked¶
FoundationDB checks conflicts only at commit. Each attempt reads at one read
version V. At commit, FoundationDB compares the attempt's read conflict
ranges with the write conflict ranges of other transactions committed after
V. An overlap rejects the commit. fdyno retries at a newer version if the
request's context has not ended and budget is left. After a conflict, a write
needs a minimum of budget left: the smaller of the commit safety margin and
1/20 of its budget.
Otherwise the request fails; see responses at the deadline. The attempt's own write conflict ranges are what later transactions are checked against.
Part of an attempt at read version V |
Conflict check |
|---|---|
| Serializable reads and explicit read conflict keys | They become read conflict ranges. At commit, an overlap with the write conflict ranges of transactions committed after V rejects the commit. fdyno retries at a new read version if the budget and the context allow. |
| Mutations | They become write conflict ranges, which later transactions are checked against. |
A read-only page or item read at V |
Never commits, so it is never checked: one snapshot, no write. |
| Read | Conflict-checked? | What it protects |
|---|---|---|
The old item in PutItem, Update, Delete and each Transact member |
Yes: a serializable read | Conditions and updates are re-evaluated on a concurrent change; no lost update. |
The table metadata for a write, current because the cluster metadata version is unchanged at V |
Yes: fdyno adds a read conflict on the revision key | A DDL change that commits after V conflicts with the write. |
Page and item reads of GetItem, Query, Scan, Batch, Transact and Get |
No: snapshot reads on the fdbget paths; on the regular path (GetRecords), the read transaction never commits | Nothing is written from these reads. The response is still one snapshot at V. The fdbget paths check the table revision at V before they return rows. |
| A worker's lease epoch | Yes: a serializable read in the effect's own transaction | A takeover after V conflicts with the old worker's effect. A snapshot read of the lease key checks the owner only; it never compares expiry with wall time. |
| A stream trim page | The page is a snapshot read. fdyno adds a read conflict on the inspected prefix, through the first record it keeps, and clears only the expired records before it | A concurrent writer inside that prefix conflicts. Stream appends commit at later versions, so they sort after every inspected key and do not conflict with the trim. |
| A PITR trim page | The page is a snapshot read. fdyno adds a read conflict on the range it clears, through the last whole commit version it trims | A concurrent writer inside the cleared range conflicts. |
Source: table_metadata.go,
write.go,
txn_write.go,
lease_fence.go,
streams.go and
pitr.go.
What retries re-evaluate¶
Consider two overlapping requests that both claim an absent key with
attribute_not_exists(pk). Both can read the key as absent. After one
commits, the other cannot commit on the same read: the write conflicts with
its read of that key. On retry the condition sees the winner's item and
fails. fdyno does not reuse the earlier condition result. A reader that
finishes while the requests overlap can still see the snapshot before the
claim. A read that starts after the successful response uses a later snapshot
in the default mode, subject to any intervening writes.
The transaction runner tests check that retries share one request budget and that read-only transactions skip commit. Strict serializability orders committed transactions; it does not promise success through contention or tell a client whether an unknown-outcome write committed.
LSI entries, GSI change records and
stream records commit with the item; a GSI read is
eventually consistent. A CREATING index rejects reads; stream delivery is at least once,
not exactly once. ConsistentRead=true on a GSI remains
rejected for API compatibility.
Not guaranteed¶
- No multi-request transactions. Two requests are two transactions.
- No snapshot across pages. Each page is a new snapshot.
- No atomic large batch.
BatchWriteItemcan commit in parts. - No order across stream shards.
- No reads from a
CREATINGindex. - No service without FoundationDB. No queued writes or stale read fallback.
When FoundationDB fails, requests fail or reach their deadline. /readyz
fails while /livez stays healthy; no uncommitted write is acknowledged. A deadline during commit can leave an
unknown outcome, not an isolation failure.
See the outage runbook.
How we know: Elle/Knossos fault histories. Qualification covers one region, FoundationDB-port partitions and API-host clock steps only. References.