Why cancelling sent work can collapse goodput¶
Cancelling a request may not remove it from the server's queue. Then the entry still takes its turn, and the retry joins the back. Cancelling only adds load. We tested this in a FIFO model that runs fdyno's real Go handlers. When requests waited, the load fully recovered. When requests gave up, the same load completed zero reads.
A model result
Every number here comes from a deterministic simulation. It is a FIFO queue model of read-version grants, driven by fdyno's real request handlers. It is not a native FoundationDB measurement. A separate, capped write comparison on a native cluster used a different workload and did not reproduce the collapse. The cancelling run used two experimental cancellation settings that fdyno had then. The totals are recorded at that commit (performance page at f5c14c43). fdyno has since removed both settings.
The queue in question¶
A FoundationDB transaction reads at one snapshot. Before it reads, the client asks the cluster for a read version (a GRV). Strong GetItem, strong Query and PutItem each start with one (calls and futures by route). When the cluster is overloaded or recovering, that answer can be slow.
fdyno used to have two experimental settings, both off by default (performance page at f5c14c43). They ended the wait early for data-plane API requests once it passed 1 s or a quarter of the request budget, whichever was shorter. DYNODB_FDB_PRESSURE_THROTTLE=1 returned ProvisionedThroughputExceededException only when a successful read version had started within that bound. It kept waiting when no read version had arrived for 5 s, or when the cluster was reported unreachable. DYNODB_FDB_OUTAGE_FAST_FAIL=1 returned a retryable 503 ServiceUnavailable in that outage case. Neither covered control-plane operations, commits, pinned reads, background work, or a request after an unknown commit outcome.
Both look like good citizenship: a fast, honest answer instead of a hung connection. The simulation enabled both. The question the simulation asked is narrower: once the request for a version has been sent, does giving up remove work?
Cancel the waiter, keep its place in the queue¶
The simulation test models the version service as a first-in, first-out queue with a fixed grant rate.
Cancelling wakes the client-side waiter. It does not remove the request that was already sent. When that entry reaches the head of the queue, it consumes a grant, and nobody is waiting for the answer. Meanwhile the client's retry has joined the back of the same queue. Cancellation shortened the client's wait and made the queue in front of its next attempt longer.
Modeled FIFO: a cancelled waiter leaves its request in the queue. When grants resume, the cancelled request still consumes a grant before later live work.
The matched schedule¶
The test fixed everything except the cancellation policy, so both runs saw the same arrivals and the same backoff draws:
| Input | Value |
|---|---|
| Request handlers | Real fdyno Go handlers in four Services sharing one FIFO |
| Stall | 6 s with no grants |
| Grant rate after the stall | 17 per second, one request per grant |
| New logical reads | 10 per second |
| Client retries | 3 attempts, full-jitter backoffs in [0, 1 s] then [0, 2 s], no retry quota |
| Length of the run | 46 s: the stall, a 30 s recovery allowance, then two 5 s scoring windows |
These are harness settings, not any SDK's defaults. Ten reads per second for 46 seconds is 460 reads. Grants run for the last 40 seconds at 17 per second: 680 grants. By arithmetic, not a test output, a waiting system has 7 grants per second of headroom after the stall. So its 60-read backlog drains in under ten seconds.
| Run | Reads completed | Grants spent on cancelled requests |
|---|---|---|
| Wait only | 460 of 460 | 0 |
| Experimental cancellation on | 0 of 460 | all 680 granted during load |
At that commit, the seed-1 control had to fail recovery with both settings on; other seeds with the settings on were observational.
Why zero, and not "fewer"? Each logical read can put up to three entries in the queue, one per attempt. That is about 30 entries per second on average, against 17 grants per second. Once a backlog of dead entries forms, a live attempt waits behind it longer than its 1 s bound. It gives up and leaves another dead entry.
Every grant then lands on an entry whose waiter has gone. This is a reading of the inputs, not a separate measurement.
No code in this run has a bug. Each request stops waiting, returns a retryable error and changes no committed key. The collapse is in the interaction between correct requests and a queue that cannot forget them. This is a metastable failure: the trigger, a six-second stall, has ended, but the system's own response keeps it down.
What fdyno does now¶
fdyno removed both settings. It never cancels a read-version request it already sent. A request waits until its time budget ends (DYNODB_OPERATION_TIMEOUT, 30 s by default) or the client cancels (when FoundationDB stalls). If either is set to 1, startup exits with an error that names it; unset it (configuration).
The current test keeps the matched stall with one waiting run. After the 30 s allowance, each 5 s window must hold at least 25 completed reads. Completions of older reads count, so this bounds throughput, not latency. Every request must return the exact expected item and leave committed state unchanged.
A sibling scene has a grv-refund control. It takes cancelled requests out of the queue and moves later requests up, as if cancellation removed sent work. Calibration must reject it, so the queue model cannot quietly forget sent work.
Limits¶
The FIFO abstracts grants. It does not model FoundationDB's native batching of read-version requests, priorities, ratekeeper or any SDK's retry defaults. A real cluster may batch many requests into one grant, which changes the arithmetic. The native comparison was a capped write workload, not this read queue. So it neither confirms nor refutes the model. It also did not rank the two policies for production.
What to do with this¶
Before you add a client-side timeout that retries, ask where the first request still sits. If the server cannot drop it, cancelling only adds load: the old entry still uses capacity, and the retry stands behind it. Cancel work only where the cancel reaches the queue, and test the policy under a stall followed by recovery, not only under steady load.