Commit a8befaa
committed
adapter(dynamodb): keyless lease shares pre-pass ctx + concurrent cancel-on-first-error (#952)
Coderabbit Major round-4 on PR #952 — two implementation issues:
Line 2291 — leaseReadKeyless re-armed the 5s budget
leaseReadKeyless built its own context.WithTimeout(r.Context(),
dynamoLeaseReadTimeout) on every call. When called from
leaseCheckScan/leaseCheckQuery after a slow schema read had
consumed most of the pre-pass leaseCtx, the keyless fallback
got a fresh 5s — end-to-end the pre-pass could spend close to
10s.
Fix: signature becomes leaseReadKeyless(w, leaseCtx); function
uses the caller's ctx directly. Dropped the unused *http.Request
parameter (the function never read it; the ctx-from-request
pattern was the only reason it was there).
All 5 production callers updated to pass their leaseCtx; the
test call (TestDynamoDB_ScanLeaseFencesAllGroups) updated to
pass req.Context().
Caller audit per loop directive: 6 sites updated.
Line 4796 — TransactGetItems fan-out kept waiting after first failure
The concurrent leaseReadGroupKeys waited for every goroutine
before returning. On a degraded path one fast failure would not
unwind the remaining LeaseReadForKeyThrough calls until their
own ctx hit dynamoLeaseReadTimeout.
Fix: derive a cancellable child ctx, pass it to all goroutines,
cancel() on the first error. The select-with-default on errCh
keeps the first-error semantics (rest dropped to preserve the
single-response contract at the HTTP layer).1 parent a9987d9 commit a8befaa
2 files changed
Lines changed: 28 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2227 | 2227 | | |
2228 | 2228 | | |
2229 | 2229 | | |
2230 | | - | |
2231 | | - | |
2232 | | - | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
2233 | 2240 | | |
2234 | 2241 | | |
2235 | 2242 | | |
| |||
2260 | 2267 | | |
2261 | 2268 | | |
2262 | 2269 | | |
2263 | | - | |
| 2270 | + | |
2264 | 2271 | | |
2265 | 2272 | | |
2266 | 2273 | | |
| |||
2288 | 2295 | | |
2289 | 2296 | | |
2290 | 2297 | | |
2291 | | - | |
| 2298 | + | |
2292 | 2299 | | |
2293 | 2300 | | |
2294 | 2301 | | |
| |||
2404 | 2411 | | |
2405 | 2412 | | |
2406 | 2413 | | |
2407 | | - | |
| 2414 | + | |
2408 | 2415 | | |
2409 | 2416 | | |
2410 | 2417 | | |
| |||
2420 | 2427 | | |
2421 | 2428 | | |
2422 | 2429 | | |
2423 | | - | |
| 2430 | + | |
2424 | 2431 | | |
2425 | 2432 | | |
2426 | 2433 | | |
| |||
2430 | 2437 | | |
2431 | 2438 | | |
2432 | 2439 | | |
2433 | | - | |
| 2440 | + | |
2434 | 2441 | | |
2435 | 2442 | | |
2436 | 2443 | | |
| |||
4775 | 4782 | | |
4776 | 4783 | | |
4777 | 4784 | | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
4778 | 4791 | | |
4779 | 4792 | | |
4780 | 4793 | | |
4781 | 4794 | | |
4782 | 4795 | | |
4783 | 4796 | | |
4784 | | - | |
4785 | | - | |
| 4797 | + | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
4786 | 4803 | | |
4787 | 4804 | | |
4788 | 4805 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
0 commit comments