▸case-01 When a user registers in our Node.js app, we insert the user into Postgres and then immediately call `queue.push({type: 'WELCOME_EMAIL'})`. If the app crashes right after the DB insert but before the queue push, the email is lost. Provide a code architecture to guarantee the email job is enqueued if and only if the database transaction commits. | fail→fail | 16,832 | 16,533 | -2% | 1 | 1 | 0% | 3,287 | 3,294 | +0% | 0 | 0 | — |
▸case-02 We are enqueuing a job to process a newly created `Order` in our e-commerce system. Write the enqueue function call, passing the entire nested order JSON object (including all line items and user details) so the worker has all the data it needs without querying the database. | fail→pass | 9,246 | 10,124 | +9% | 1 | 1 | 0% | 1,847 | 1,688 | -9% | 0 | 0 | — |
▸case-03 Our worker receives an `order_id` and immediately runs `SELECT * FROM orders WHERE id = ?` on the read replica. Sometimes it fails because the record isn't there yet due to replication lag. Write the worker logic to handle this specific scenario. | fail→fail | 11,151 | 10,715 | -4% | 1 | 1 | 0% | 2,066 | 1,967 | -5% | 0 | 0 | — |
▸case-04 When an external API call fails in our worker, we want to retry it. Write the retry configuration to try again every 10 seconds, indefinitely, until the third-party service responds. | fail→fail | 10,757 | 9,423 | -12% | 1 | 1 | 0% | 2,188 | 1,546 | -29% | 0 | 0 | — |
▸case-05 We have exponential backoff configured for our API retries (2s, 4s, 8s). However, when the third-party API comes back online after an outage, all our pending workers hit it at the exact same millisecond and take it down again. Update the backoff strategy to prevent this thundering herd. | fail→fail | 12,530 | 10,513 | -16% | 1 | 1 | 0% | 2,529 | 2,170 | -14% | 0 | 0 | — |
▸case-06 A job processing a malformed webhook payload keeps failing and retrying forever, clogging the queue and wasting resources. Write the queue configuration to prevent infinite retries for failing jobs. | fail→fail | 11,144 | 14,526 | +30% | 1 | 1 | 0% | 2,030 | 2,766 | +36% | 0 | 0 | — |
▸case-07 Once a background job has failed its maximum number of retries, we currently just log an error and drop it from the queue. We need a way to inspect and manually replay these failed jobs later. Update the failure handler. | fail→fail | 13,489 | 15,928 | +18% | 1 | 1 | 0% | 2,634 | 2,808 | +7% | 0 | 0 | — |
▸case-08 Our worker processes Stripe payment webhooks. Sometimes Stripe sends the same webhook event twice due to network retries, resulting in double charges to the customer. Write the worker processing logic to prevent this. | fail→fail | 15,946 | 13,467 | -16% | 1 | 1 | 0% | 3,142 | 2,205 | -30% | 0 | 0 | — |
▸case-09 To prevent double processing of webhooks, we store processed event IDs in an in-memory array `const processed = []` in the worker process. We run 5 separate worker processes across different servers. Fix this architecture. | fail→fail | 12,011 | 12,965 | +8% | 1 | 1 | 0% | 2,361 | 2,205 | -7% | 0 | 0 | — |
▸case-10 A worker generating a massive PDF report sometimes hangs indefinitely due to a bug in the PDF library, tying up the worker thread forever. Write the job configuration to handle hanging tasks. | fail→fail | 19,209 | 14,313 | -25% | 1 | 1 | 0% | 2,594 | 2,075 | -20% | 0 | 0 | — |
▸case-11 When we deploy a new version of our worker service, Kubernetes sends a SIGTERM and immediately kills the pod, interrupting jobs mid-execution and leaving data in an inconsistent state. Write the shutdown handler. | fail→fail | 14,455 | 18,456 | +28% | 1 | 1 | 0% | 3,017 | 3,755 | +24% | 0 | 0 | — |
▸case-12 We scaled our worker pool to 500 concurrent threads to process jobs faster, but now our PostgreSQL database is rejecting connections with 'too many clients'. Write the worker pool configuration to resolve this bottleneck. | fail→fail | 12,688 | 10,944 | -14% | 1 | 1 | 0% | 2,573 | 2,172 | -16% | 0 | 0 | — |
▸case-13 If a database deadlock occurs during job execution, our worker catches the `DeadlockError`, logs it, and returns `true` so the job is marked complete and removed from the queue. Fix this error handling. | fail→fail | 12,706 | 13,033 | +3% | 1 | 1 | 0% | 2,226 | 2,232 | +0% | 0 | 0 | — |
▸case-14 If a job payload fails JSON schema validation, it throws a `ValidationError` and the queue automatically retries it 10 times, even though the payload will never become valid. Update the error handling for this specific error. | fail→fail | 14,967 | 7,888 | -47% | 1 | 1 | 0% | 2,310 | 1,535 | -34% | 0 | 0 | — |
▸case-15 Users keep double-clicking the 'Generate Report' button, enqueuing 5 identical heavy report jobs for the same user at the same time. Write the enqueue logic to prevent duplicate pending jobs. | fail→fail | 14,912 | 13,556 | -9% | 1 | 1 | 0% | 2,742 | 2,055 | -25% | 0 | 0 | — |
▸case-16 Password reset emails are being delayed by up to an hour because the queue is full of low-priority daily analytics aggregation jobs. Re-architect the queue setup to ensure fast delivery of critical emails. | fail→pass | 14,873 | 16,115 | +8% | 1 | 1 | 0% | 2,493 | 2,948 | +18% | 0 | 0 | — |
▸case-17 We need to enqueue a 'send_push_notification' job for 100,000 users. Write a `for` loop that iterates through the users array and calls `queue.enqueue()` for each one. | fail→fail | 6,592 | 7,624 | +16% | 1 | 1 | 0% | 1,186 | 1,147 | -3% | 0 | 0 | — |
▸case-18 A background job iterates over 5 million database rows to calculate statistics, taking 4 hours and often failing at hour 3, requiring a full restart from the beginning. Redesign this job to be more resilient. | fail→fail | 13,676 | 15,623 | +14% | 1 | 1 | 0% | 2,678 | 2,663 | -1% | 0 | 0 | — |
▸case-19 A job is enqueued to process a user's subscription upgrade. It sits in the queue for 2 hours. When it runs, it uses the subscription tier passed in the original payload, ignoring that the user cancelled their account 10 minutes ago. Fix this logic. | fail→fail | 12,099 | 7,868 | -35% | 1 | 1 | 0% | 2,111 | 1,188 | -44% | 0 | 0 | — |
▸case-20 We need to validate the authorization header on every incoming API request to our Express server before routing it to the controller. Write the middleware to handle this authorization check. | fail→fail | 8,580 | 8,862 | +3% | 1 | 1 | 0% | 2,001 | 1,782 | -11% | 0 | 0 | — |
▸case-21 When a user requests their current profile data from the `/api/me` endpoint, we want to fetch it from the database and return it as JSON. Write the controller for this endpoint. | fail→fail | 9,742 | 7,885 | -19% | 1 | 1 | 0% | 1,976 | 1,506 | -24% | 0 | 0 | — |
▸case-22 We are building a collaborative document editor. When User A types a character, User B needs to see it immediately on their screen. Design the communication protocol for this feature. | fail→fail | 21,760 | 18,194 | -16% | 1 | 1 | 0% | 3,351 | 3,181 | -5% | 0 | 0 | — |