Commit f29174b
committed
RUBY-3770 Implement makeTimeoutError semantics in withTransaction
Per DRIVERS-3391 / transactions-convenient-api spec, withTransaction must
propagate a TimeoutError (wrapping the last transient error as .cause) when
the CSOT deadline is exhausted, instead of re-raising the raw error.
Changes to lib/mongo/session.rb:
- Callback raises TransientTransactionError + deadline expired: raise
TimeoutError in CSOT mode, re-raise original in non-CSOT mode.
- Commit raises UnknownTransactionCommitResult + deadline expired: same.
- Commit raises TransientTransactionError + deadline expired: same.
- Backoff (regular and overload) would exceed deadline: use new
make_timeout_error_from helper — CSOT wraps last_error with cause,
non-CSOT raises last_error directly (fixes incorrect TimeoutError
that was raised in non-CSOT mode before this change).
- Commit overload backoff would exceed deadline: raise TimeoutError in
CSOT mode, re-raise in non-CSOT mode.
- Add make_timeout_error_from private helper implementing the
makeTimeoutError(lastError) pseudocode from the spec. Uses an inner
begin/rescue to wire .cause when called outside a rescue block.
New spec/mongo/session/with_transaction_timeout_spec.rb covers all eight
code paths as unit tests with stubbed time control (no real server needed).1 parent 680e19e commit f29174b
2 files changed
Lines changed: 410 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
487 | | - | |
| 487 | + | |
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
516 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
517 | 521 | | |
518 | 522 | | |
519 | 523 | | |
| |||
554 | 558 | | |
555 | 559 | | |
556 | 560 | | |
557 | | - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
558 | 566 | | |
559 | 567 | | |
560 | 568 | | |
| |||
569 | 577 | | |
570 | 578 | | |
571 | 579 | | |
572 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
573 | 585 | | |
574 | 586 | | |
575 | 587 | | |
| |||
591 | 603 | | |
592 | 604 | | |
593 | 605 | | |
594 | | - | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
595 | 611 | | |
596 | 612 | | |
597 | 613 | | |
| |||
1436 | 1452 | | |
1437 | 1453 | | |
1438 | 1454 | | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
1439 | 1475 | | |
1440 | 1476 | | |
0 commit comments