Designing Retry vs Skip Policy in Production
Fast recall
Quick revision
Core answer
Whether you can map exception taxonomy to fault-tolerance policy and write non-trivial RetryPolicy/SkipPolicy implementations
Catching `Exception.class` for both skip and retry, masking real bugs and turning data corruption into a silent failure mode
Discuss percentage-based skip tolerance, the difference between `RetryPolicy` and `BackOffPolicy`, and a circuit-breaker SkipPolicy that flips the step to FAILED when error rate exceeds a threshold mid-run
Interview-ready guide
Interview answer
The retry-vs-skip choice is driven by exception class semantics, not by a single tunable.
Map exceptions to actions:
- Transient infrastructure (deadlock, 503, timeout) → retry with exponential backoff
- Permanent data defects (parse, validation, business rule violation) → skip with SkipListener
- Fatal logic errors (NullPointerException, OutOfMemoryError) → fail fast
Custom RetryPolicy when you need nuance:
ExceptionClassifierRetryPolicyfor per-class retry limits- Custom
canRetry()for circuit-breaker behavior — bail out after N total failures across the step RetryPolicydecides whether to retry;BackOffPolicydecides how long to wait — they compose
Custom SkipPolicy when absolute counts aren't enough:
PercentageSkipPolicy— fail fast if more than 5% of items skip after a warmup window- Tiered policy — allow 1000 parse errors but only 10 integrity violations
- Stateful policies need
AtomicLongfor multi-threaded steps
Always pair skip with a SkipListener:
- Write skipped items to a Kafka topic, file, or audit table
- Without this you've created a silent data-loss vector
Anti-patterns to avoid:
skip(Exception.class)— masks real bugs- Retry without backoff — retry storms compound the original failure
- Retrying on non-idempotent processors — duplicate side effects
- The same policy for transient and permanent errors
The ambiguous case:
DataIntegrityViolationException— UNIQUE constraint may be a permanent duplicate (skip) or a transient race (retry)- Inspect the cause or message and route accordingly
In an interview I'd emphasize that the retry-vs-skip choice starts with exception classification, and that production-grade policies often need custom implementations to capture business risk tolerance.
Designing Retry vs Skip Policy in Production
Direct Answer
The retry-vs-skip choice is driven by exception class semantics: transient infrastructure failures (deadlock, timeout, 503) get retry; permanent data defects (parse error, validation, schema mismatch) get skip; fatal logic errors (NullPointerException, IllegalStateException) get neither — fail fast and investigate. For nuanced control, implement custom RetryPolicy.canRetry(RetryContext) to limit retries per exception type or per business key, and custom SkipPolicy.shouldSkip(Throwable, long) to enforce per-exception caps, percentage tolerances, or circuit-breaker behavior that fails the step when error rate exceeds a threshold mid-run.
Common Mistakes & Pitfalls
Catching Exception.class for both skip and retry, masking real bugs and turning data corruption into a silent failure mode
Check your understanding
Answer these without looking back at the article.
- How do you ensure a custom SkipPolicy works correctly in a multi-threaded step?
- What happens to skip and retry counters when a step is restarted from a checkpoint?
- Why might `DataIntegrityViolationException` need different handling for UNIQUE vs FOREIGN KEY violations?
- How would you implement a per-business-key retry limit so the same broken record doesn't waste 100 retry attempts?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.