withRetryTx replays a write that lost Dolt's commit-time merge on an
exponential schedule: waits from 25ms, multiplier 1.5, jitter of half a
wait either way, within 15s on a sql-server (5s embedded). The schedule set
no MaxInterval, so it used the library default of 60s, and the waits grew
to 2-5s each before the budget ran out. A writer that keeps losing
conflicts got at most 16 attempts in the server budget (14-15 typically).
That is routine when every mutation bumps one shared row, as it does with
the events journal on and several concurrent writers.
newWriteTxRetryBackOff now builds the schedule, and caps each wait at
writeTxRetryMaxInterval (1s) before jitter. The budget and the first waits
are unchanged; the later attempts keep arriving at about one a second. On
the schedule alone, with attempts taking no time, the 15s budget now
yields 19-29 attempts (median 23) instead of 14-16 (median 15), measured
over 200,000 jittered runs; the worst case, every wait jittered to its
longest, yields 18. The embedded budget goes from 11-13 to 11-16.
Test: TestWriteTxRetryScheduleKeepsRetryingAcrossItsBudget drives
newWriteTxRetryBackOff with a stepping clock (no sleeps), 50 jittered runs
per mode. It checks that no wait exceeds the jittered cap (1.5s), that the
schedule stays within its budget, and that a writer gets at least 18
attempts in 15s on a server and 11 in 5s embedded. With the schedule
extracted but uncapped it fails ("wait 2.631086165s exceeds the jittered
cap of 1.5s"); with only the cap check disabled, it reports "a writer that
keeps losing gets 15 attempts in 15s, want at least 18". It passes with
the cap. The package's Retry|Circuit|Serialization|Indeterminate|
Concurrent|WriteTx tests pass against a dolt sql-server 2.2.0 test
container.
Agent-Signature: claude-code-claude-opus-5-5-max on behalf of Julian Knutsen
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>