Datasets:
INC8: Cascading Timeout
Goal
A 3-service request chain has timeout misconfigurations that cause cascading failures, plus retry policies that amplify the problem. Fix the timeout cascade and the 2 harmful retry configurations while preserving the 2 correct retries.
Requirements
- Fix the timeout cascade: upstream timeouts must be >= downstream timeouts
- Fix the 2 harmful retry configurations
- Preserve the 2 correct retry configurations (documented in
RETRY_POLICY.md) - All tests must pass after changes:
pytest tests/
Architecture
Three services form a synchronous request chain:
gateway.py --> order_service.py --> inventory_service.py
Each service has configurable timeout and retry settings.
Timeout Cascade Bug
The gateway timeout (5s) is SHORTER than the order_service timeout (10s). When the order_service takes 6-10 seconds to respond, the gateway times out first, returning an error to the client. Meanwhile, the order_service continues processing (zombie request), potentially completing a state-changing operation that the client thinks failed.
Fix: gateway timeout must be >= order_service timeout + buffer. Similarly, order_service timeout must be >= inventory_service timeout + buffer.
Retry Configurations (4 total)
Correct Retries (preserve these)
Idempotent GET retry:
GET /inventory/checkretries on timeout are safe because the operation is read-only. Documented inRETRY_POLICY.md.Health check retry:
/healthendpoint retries are safe because health checks are idempotent and stateless. Documented inRETRY_POLICY.md.
Harmful Retries (fix these)
Non-idempotent POST retry:
POST /orders/createretries on timeout. If the first request succeeded but the response was lost (timeout), the retry creates a duplicate order and double-charges the customer. Fix: disable retry for non-idempotent operations, or require idempotency keys.Retry storm amplification: When inventory_service is slow, order_service retries 3 times. Each retry causes gateway to also retry, creating 3x3=9 total requests to inventory_service from a single client request. Fix: add retry budget or circuit breaker to prevent amplification.
Supporting Files
gateway.py— API gateway with timeout and retry configorder_service.py— order processing serviceinventory_service.py— inventory checking serviceINCIDENT_REPORT.md— documents a past cascading timeout incidentRETRY_POLICY.md— documents which operations are idempotentconfig.py— service configuration (timeouts, retry counts)tests/test_services.py— service tests (must all pass)