Commit f8582a0
authored
## Summary
- Distinguish `TransactionConflict` from `ConditionalCheckFailed` in
`_is_condition_check_failure()` by inspecting `CancellationReasons`
codes instead of treating all `TransactionCanceledException` the same
- Add `_is_transaction_conflict()` helper and retry loop with
exponential backoff (25ms base, 3 retries) for transient contention
errors in `_commit_initial()`
- Fix `_build_retry_failure_statuses()` to compute `retry_after_seconds`
from bucket state via `calculate_retry_after()` instead of hardcoding
`0.0`
- Apply identical fixes to both async (`lease.py`) and sync
(`sync_lease.py`) code paths
## Test plan
- [x] Unit tests for `_is_condition_check_failure()`: pure
ConditionalCheckFailed, pure TransactionConflict, mixed reasons, no
response attribute
- [x] Unit tests for `_is_transaction_conflict()`: pure conflict,
condition-check-only, unrelated exceptions, ClientError fallback
- [x] Unit test: TransactionConflict retries original transaction (not
consumption-only path)
- [x] Unit test: TransactionConflict exhausts retries and propagates
exception
- [x] Unit test: ConditionalCheckFailed still enters consumption-only
retry path (regression)
- [x] Unit test: mixed reasons prefer ConditionalCheckFailed over
TransactionConflict
- [x] Unit test: cascade TransactionConflict does not raise false
RateLimitExceeded (issue scenario)
- [x] Unit test: `_build_retry_failure_statuses()` computes non-zero
`retry_after_seconds` from deficit
- [x] Unit test: `_build_retry_failure_statuses()` returns 0.0 when no
deficit
- [ ] Run full unit test suite: `uv run pytest tests/unit/ -v`
Closes #332
š¤ Generated with [Claude Code](https://claude.ai/code)
4 files changed
Lines changed: 720 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | | - | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
13 | 18 | | |
14 | 19 | | |
15 | 20 | | |
| |||
262 | 267 | | |
263 | 268 | | |
264 | 269 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
270 | 296 | | |
| 297 | + | |
271 | 298 | | |
272 | 299 | | |
273 | 300 | | |
| |||
402 | 429 | | |
403 | 430 | | |
404 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
405 | 449 | | |
406 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
407 | 455 | | |
408 | | - | |
| 456 | + | |
409 | 457 | | |
410 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
411 | 463 | | |
412 | 464 | | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 465 | + | |
417 | 466 | | |
418 | 467 | | |
419 | 468 | | |
420 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
421 | 483 | | |
422 | 484 | | |
423 | 485 | | |
424 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
425 | 493 | | |
426 | 494 | | |
427 | 495 | | |
| |||
431 | 499 | | |
432 | 500 | | |
433 | 501 | | |
434 | | - | |
| 502 | + | |
435 | 503 | | |
436 | 504 | | |
437 | 505 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
232 | 234 | | |
233 | 235 | | |
234 | 236 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
239 | 258 | | |
| 259 | + | |
240 | 260 | | |
241 | 261 | | |
242 | 262 | | |
| |||
339 | 359 | | |
340 | 360 | | |
341 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
342 | 379 | | |
343 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
344 | 385 | | |
345 | | - | |
| 386 | + | |
346 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
347 | 391 | | |
348 | 392 | | |
349 | | - | |
| 393 | + | |
350 | 394 | | |
351 | 395 | | |
352 | 396 | | |
353 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
354 | 411 | | |
355 | 412 | | |
356 | 413 | | |
357 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
358 | 421 | | |
359 | 422 | | |
360 | 423 | | |
| |||
364 | 427 | | |
365 | 428 | | |
366 | 429 | | |
367 | | - | |
| 430 | + | |
368 | 431 | | |
369 | 432 | | |
370 | 433 | | |
0 commit comments