FoundationDB Transaction Retry: Server-Side Idempotency Token Absence
0 reputation · 01 Sept 2022, 22:19 UTC
0 reputation · 01 Sept 2022, 22:19 UTC
FoundationDB's optimistic concurrency control returns retryable errors (transaction_too_old, not_committed) when read-write conflicts occur. The on_error callback automatically re-executes the entire transaction function, which re-applies any writes unless the application implements idempotency at the key level.
Current patterns require embedding unique request identifiers into keys or using versionstamped fields with pre-write existence checks. This adds read latency to every mutating transaction and only works when uniqueness is expressible in the key space. The database does not expose an idempotency_token parameter or server-side deduplication mechanism in the current fdb.Transaction API.
Whether FoundationDB should introduce a first-class idempotency token that the cluster tracks and rejects duplicate submissions—similar to Stripe's idempotency keys—versus leaving this entirely to application-layer design remains unresolved.
Should a server-side idempotency token be scoped to the transaction, the session, or a configurable TTL? Would token tracking require coordinator consensus or partition-local state? Can the feature coexist with the existing on_error retry semantics without introducing new failure modes?
33775 reputation · 02 Sept 2022, 03:05 UTC
FoundationDB does not provide a server‑side idempotency token mechanism. The cluster does not track, deduplicate, or reject duplicate transaction submissions. Every retry triggered by transaction_too_old (1007) or not_committed (1024) re‑executes the entire transaction function from the start. Applications must implement idempotency themselves—typically by embedding request identifiers in keys, using versionstamped guard keys with conditional writes, or maintaining an external deduplication store.
idempotency_token option exists in fdb_transaction_set_option or any language binding.on_error retry is purely client‑side; the cluster sees each attempt as a new transaction with a new read version.FoundationDB's kernel philosophy treats idempotency as an application‑layer concern, consistent with its lack of secondary indexes, triggers, and stored procedures. Adding server‑side token tracking would require:
on_error semantics: a server‑side token must survive client restarts and coordinate with the existing retry loop to avoid double‑apply or lost‑update anomalies.Stripe‑style idempotency keys assume request‑response semantics (single HTTP call). FoundationDB's interactive transactions—multiple reads and writes before commit—make token scope ambiguous: per‑transaction, per‑session, or per‑client‑defined boundary?
| Pattern | How It Works | Cost |
|---|---|---|
| Request ID in key suffix | /request/{uuid}/payload = value | Couples business logic to key layout; sequential UUIDs cause hot partitions |
| Versionstamp guard key | SET_IF_NOT_PRESENT /idempotency/{token} = versionstamp() | Requires extra read on retry; only prevents duplicate key creation, not re‑execution of other writes unless whole transaction is conditional |
| External deduplication store | Redis/SQL with SETNX or unique constraint | New failure domain; consistency window between external store and FDB commit |
# Submit the same conflicting transaction twice; both commit if the second retry succeeds
fdbcli --exec \"configure single memory; create; open\"
# In a client: run a transaction that writes key A, then immediately retry it with on_error
# Observe: no deduplication occurs; the second attempt commits independently
Are you experiencing actual duplicate side effects (double charges, double emails) in production, or is this a design‑time concern? If duplicates are occurring, the immediate fix is a versionstamp guard key with a conditional transaction; a server‑side token would not ship in any current FDB release.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.