ADR-004: Bound placement retries with scheduled saga timeouts
Finance uses Wolverine timeout messages and a persisted counter to bound placement-command reissues, cancelling only the saga on exhaustion.
1. Context & Problem
Post-checkout coordination in Finance SystemSystemv1.0.0Finance SystemInternal BookWorm workflow system that coordinates post-checkout basket cleanup and order notifications through Durable ...Ownercommerce-fulfillment-teamDiagramOpen docs cannot wait indefinitely for downstream progress, yet immediate or unlimited retries could worsen an outage in Basket APIServicev1.0.0Basket APIInternal HTTP and gRPC service for managing customer-scoped shopping baskets, Catalog price enrichment, and post-checkou...PublishesGetBookGrpc, GetBooksGrpc +2SubscribesCreateBasket, UpdateBasket +4APIsOpenAPI, AsyncAPIOwnercommerce-fulfillment-teamDiagramRepositoryOpen docs or the messaging layer. Finance already maintains durable workflow state and scheduled reminders, so it needed a bounded retry mechanism that:
- Limits how many times a placement request is reissued.
- Spaces attempts out to allow transient issues time to clear.
- Distinguishes a missing cleanup confirmation from an authoritative Order cancellation in OrderingDomainv1.0.0OrderingCreates durable Orders from a buyer's current basket, locks purchase-time pricing, and owns order lifecycle transitions ...Ownercommerce-fulfillment-teamDiagramOpen docs.
This retrospective ADR documents the timeout behavior actually implemented, including its known caveats rather than an idealized retry design.
2. Business Value
- Outage protection: Spacing retries apart and capping total attempts prevents Finance from flooding an unhealthy dependency with retry traffic.
- Bounded operational lifespan: Workflows do not remain stuck open indefinitely when expected cleanup confirmations never arrive.
- Preserved source of truth: When retries run out, Finance closes only its internal coordination workflow rather than prematurely cancelling the customer’s Order.
- Survives restarts: Because the retry count and scheduled checks are persisted, restarts do not reset the limit or lose track of active workflows.
3. How It Works
- Initial request and timer: When a checkout workflow starts, Finance sends the initial placement request and schedules a follow-up check for 30 minutes later.
- Bounded reissues: Each time a scheduled check fires, Finance increments its saved attempt count. Under the configured limit of 3 attempts, a full uninterrupted sequence sends the initial request plus 2 reissues; the third timeout exhausts the retry budget.
- Immediate stop on explicit failure: If Basket explicitly reports that cleanup failed, Finance closes its workflow right away instead of waiting through the remaining scheduled checks.
- Open-workflow overlap on cleanup success: When Basket reports cleanup success, Finance forwards that progress, but the workflow stays open waiting for the final Order outcome and does not cancel the scheduled check. As a result, a still-open workflow can receive a later timeout and reissue the placement request even after cleanup succeeded.
- Closure on exhaustion: Once the retry limit is reached, Finance marks its internal workflow as cancelled, closes it, and requests a cancellation email only when both customer name and email are nonblank. It never calls Ordering to cancel the Order itself.
4. Trade-offs & Lessons Learned
Alternatives Considered
- Retrying indefinitely: Keeps trying during long outages, but amplifies downstream load and leaves coordination records open forever.
- Retrying immediately: Gives failing services no time to recover and increases pressure during partial outages.
- Cancelling the Order on retry exhaustion: Would turn an internal coordination timeout into an unauthorized business-status change, creating competing owners for the Order lifecycle.
- Publishing a cross-service timeout event: Would misrepresent an internal timer as an external integration contract across services.
Operational Realities & Caveats
- Repeated downstream work: Because reissuing the placement request targets a shared contract consumed by both Basket and Notification—and because cleanup success does not cancel pending timeouts—retries can trigger duplicate basket cleanup attempts and additional emails. Downstream consumers and operations teams must account for repeated processing.
- Intervals, not strict SLAs: The 30-minute delay governs the gap between scheduled checks; scheduling delays, queue backlogs, or downstream latency mean it is not a guaranteed wall-clock completion deadline.
- Workflow retries vs. transport retries: These scheduled workflow reissues operate at the coordination level and are distinct from lower-level message-broker delivery retries.
- Internal closure only: A Finance timeout exhaustion updates only Finance’s workflow state; it does not prove that Ordering cancelled the Order or that a cancellation email reached the customer.
5. Technical Reference
Implemented Retry Algorithm & Configuration
- Initial emission: At saga start, emit Place orderCommandv1.0.0Place orderShared Finance order-placement command consumed by Notification to render
and submit a new-order email.
Ownerplatform-engineering-teamSchemaDiagramOpen docs and schedule a local
PlaceOrderTimeout(OrderId, MaxRetryTimeout)message. - Timeout handling: On each timeout, increment persisted
TimeoutRetryCount. WhileTimeoutRetryCountis less thanMaxAttempts, reissue Place orderCommandv1.0.0Place orderShared Finance order-placement command consumed by Notification to render and submit a new-order email. Ownerplatform-engineering-teamSchemaDiagramOpen docs and schedule another timeout. - Checked-in settings:
MaxAttempts: 3with a 30-minute delay (1 initial command + 2 reissues; the 3rd timeout exhausts the limit). - Exhaustion behavior: Mark the saga
Cancelled, callMarkCompleted(), and emit a cancellation notification command (Send order cancelled notificationCommandv1.0.0Send order cancelled notificationShared Finance cancellation command consumed by Notification to render and submit a canceled-order email. Ownerplatform-engineering-teamSchemaDiagramOpen docs) only when both recipient name and email are nonblank. Do not invoke OrderingDomainv1.0.0OrderingCreates durable Orders from a buyer's current basket, locks purchase-time pricing, and owns order lifecycle transitions ...Ownercommerce-fulfillment-teamDiagramOpen docs‘s cancel operation.
Contracts & Messaging Notes
| Item | Detail |
|---|---|
| Scheduled timeout mechanism | Local Wolverine TimeoutMessage (PlaceOrderTimeout) — not the documented-but-unused PlaceOrderTimeoutIntegrationEvent Kafka contract. |
| Reissued command | Place orderCommandv1.0.0Place orderShared Finance order-placement command consumed by Notification to render and submit a new-order email. Ownerplatform-engineering-teamSchemaDiagramOpen docs (consumed by both Basket and Notification). |
| Saga persistence | Retry count (TimeoutRetryCount) and saga state persist across process restarts. |
| Basket-success side effect | Does not cancel outstanding timeouts or complete the saga; later timeouts can still reissue Place orderCommandv1.0.0Place orderShared Finance order-placement command consumed by Notification to render and submit a new-order email. Ownerplatform-engineering-teamSchemaDiagramOpen docs. |
| Explicit basket-failure behavior | Ends the saga immediately rather than consuming remaining timeout attempts. |