Challenge - 5 Problems
Rails Job Retry Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What happens when a job raises an exception in Active Job with default retry settings?
Consider a Rails Active Job that raises an exception during execution. What is the default behavior regarding retries and job failure?
Ruby on Rails
class ExampleJob < ApplicationJob def perform raise "Something went wrong" end end ExampleJob.perform_later
Attempts:
2 left
💡 Hint
Active Job does not retry by default; retry_on must be configured.
✗ Incorrect
By default, without retry_on, Active Job does not retry jobs that raise an exception; the job fails immediately.
📝 Syntax
intermediate2:00remaining
Which syntax correctly sets a custom retry count for a job in Rails Active Job?
You want to configure a job to retry only 5 times on failure. Which code snippet correctly sets this retry count?
Attempts:
2 left
💡 Hint
Check the official Active Job retry_on method options.
✗ Incorrect
The correct option uses attempts: 5 to set the retry count.
🔧 Debug
advanced2:00remaining
Why does this job never retry despite using retry_on?
Given the following job code, why does the job not retry after raising a RuntimeError?
Ruby on Rails
class NoRetryJob < ApplicationJob retry_on ArgumentError, attempts: 3 def perform raise RuntimeError, "fail" end end
Attempts:
2 left
💡 Hint
Check which exception class retry_on is configured to handle.
✗ Incorrect
The job only retries on ArgumentError, but it raises RuntimeError, so no retry happens.
❓ state_output
advanced2:00remaining
What is the state of a job after all retries are exhausted?
If a job configured with retry_on fails all retry attempts, what is the final state of the job in the queue system?
Attempts:
2 left
💡 Hint
Think about what happens when retries are exhausted in background job systems.
✗ Incorrect
After all retries, the job is marked failed and usually moved to a dead queue or discarded.
🧠 Conceptual
expert3:00remaining
How can you implement exponential backoff for retries in Rails Active Job?
You want your job retries to wait longer after each failure, doubling the wait time each retry (exponential backoff). Which approach correctly implements this behavior?
Attempts:
2 left
💡 Hint
Consider how retry_on blocks can customize retry behavior and delay.
✗ Incorrect
retry_on accepts a block where you can control the retry delay dynamically based on the retry count, enabling exponential backoff.