Calculate next retry eligibility after exponential backoff
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
For queued jobs with attempts>0 use delay=2^attempts minutes after last_attempt. Return job_id,next_eligible_minute,ready_at20 flag; calculate powers by recursive doubling rather than unsupported functions. Sort job_id.

OUTPUT
job_id, next_eligible_minute, ready_at20

RULES
For queued jobs with attempts>0 use delay=2^attempts minutes after last_attempt. Return job_id,next_eligible_minute,ready_at20 flag; calculate powers by recursive doubling rather than unsupported functions. Sort job_id.
Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.

FIELD DICTIONARY
jobs:
  id INTEGER — Stable source record identifier; not a row position.
  tenant TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  priority INTEGER — Higher integer means higher priority in this case.
  created INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  status TEXT — Literal lifecycle label; use only statuses eligible in the task.
  lease_until INTEGER — Exclusive UTC minute until which running ownership remains valid.
  attempts INTEGER — Number of attempts already made.
  last_attempt INTEGER — UTC minute of most recent attempt, NULL if never attempted.
  skill TEXT — Literal business key or category label. Match exactly and retain NULL where present.

dependencies:
  job_id INTEGER — Foreign business-record identifier; match to the named source key.
  needs_id INTEGER — Foreign business-record identifier; match to the named source key.

workers:
  id TEXT — Stable source record identifier; not a row position.
  skill TEXT — Literal business key or category label. Match exactly and retain NULL where present.

METHOD
For queued jobs with attempts>0 use delay=2^attempts minutes after last_attempt. Return job_id,next_eligible_minute,ready_at20 flag; calculate powers by recursive doubling rather than unsupported functions. Sort job_id.
For the first output record, job_id = 3; next_eligible_minute = 14; ready_at20 = 1.
Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.

COMMON WRONG TURN
Using attempts*2 instead of 2^attempts creates linear rather than exponential backoff.

RESULT CHECK
For the first output record, job_id = 3; next_eligible_minute = 14; ready_at20 = 1.

Use setup.sql in a fresh SQLite database and run your own SELECT or WITH. reference.sql and expected.csv contain the full worked answer. All CSVs have UTF-8 headers; empty output fields represent NULL. The browser executes SQLite, not Excel formulas. No spreadsheet function engine is claimed.
