Job queue · replay
A timeout costs one job 2 s, not the whole queue
A job that times out waits a short backoff and rejoins the back of the queue. The other jobs keep running.
- A burst of five jobs arrives at once.
- Admit lets all five in, because the queue holds eight (admit.ts:14).
- Two jobs start and three wait, because the pool has two workers (pool.ts:8).
- J1 uploads and passes, so it is done (worker.ts:52).
- The free worker takes J3 from the front, because a slot opened (pool.ts:21).
- J2 runs past 30 s, so it fails, waits 2 s, and rejoins the back of the queue (retry.ts:22).
- The rest run in order. J2 passes on its second try.
- All five are done. Each dot is a job; about one in ten takes the retry loop.
Sources
Illustrative: src/jobs/admit.ts:14 · src/jobs/pool.ts:8, 21 · src/jobs/worker.ts:52 · src/jobs/retry.ts:22. The service is an example, not a real codebase.