Commit 3dcf15e
Mark idempotent FoundationDB transactions as retryable (#37062)
### Motivation
FoundationDB transactions can fail with a `commit_unknown_result` error,
indicating the transaction may or may not have committed. Currently, all
transactions in the timestamp oracle use `TransactOption::default()`,
which causes these errors to propagate as failures rather than being
retried.
Several transactions in the timestamp oracle are idempotent and safe to
retry on this error:
- Read-only transactions (they have no side effects)
- Transactions that use `GREATEST()` to monotonically advance values
(retries only move the value further forward)
This change improves reliability by allowing safe retries instead of
failures.
Closes PER-25.
### Description
Updated four transaction sites in
`src/timestamp-oracle/src/foundationdb_oracle.rs` to use
`TransactOption::idempotent()` instead of `TransactOption::default()`:
1. **`max_read_ts()`** — Pure read transaction, safe to retry
2. **`write_ts()` in `TimestampOracle::next()`** — Uses `max(write_ts +
1, proposed_next_ts)`, so retries only advance the timestamp further
while preserving monotonicity
3. **`peek_write_ts()`** — Pure read transaction, safe to retry
4. **`read_ts()`** — Pure read transaction, safe to retry
5. **`apply_write()`** — Uses `GREATEST(current, write_ts)` to bump
values, making it idempotent; retries cannot cause regression
Each change includes a comment explaining why the transaction is safe to
retry on `commit_unknown_result` errors.
### Verification
No new tests added — this change improves error handling for existing
transaction patterns. The idempotency properties are documented in the
code comments and follow from the transaction logic (read-only
operations and monotonic value updates via `GREATEST()`).
https://claude.ai/code/session_012DArBrNjtGVVBSdTomhsuF
Co-authored-by: Claude <noreply@anthropic.com>1 parent e0f4198 commit 3dcf15e
1 file changed
Lines changed: 20 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
238 | 241 | | |
239 | 242 | | |
240 | 243 | | |
| |||
482 | 485 | | |
483 | 486 | | |
484 | 487 | | |
485 | | - | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
486 | 494 | | |
487 | 495 | | |
488 | 496 | | |
| |||
515 | 523 | | |
516 | 524 | | |
517 | 525 | | |
518 | | - | |
| 526 | + | |
| 527 | + | |
519 | 528 | | |
520 | 529 | | |
521 | 530 | | |
| |||
544 | 553 | | |
545 | 554 | | |
546 | 555 | | |
547 | | - | |
| 556 | + | |
| 557 | + | |
548 | 558 | | |
549 | 559 | | |
550 | 560 | | |
| |||
576 | 586 | | |
577 | 587 | | |
578 | 588 | | |
579 | | - | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
580 | 595 | | |
581 | 596 | | |
582 | 597 | | |
| |||
0 commit comments