opentextbooks: a run can completely fail with a misleading "all books failed" error when only open.umn.edu's own rate-limiting kicks in
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 20/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend, networking
Research direction
Start with core/download_engine.py and its fetch_bytes_with_retry handling of 429 responses, then read core/pipeline.py's process_one() to see how attempts affect progress and failures. Compare the shared host pacing and Retry-After handling described for sotoki and mwoffliner. Done means throttled requests are paced or retried appropriately and progress or the final error distinguishes attempts from successful books; pull request #212 is already open.
Written by the indexing model from the issue text.
Description
Summary
A real production task (open-textbook-library_ko_all, task fefe81ae-9a44-4137-b920-b1bc8cb33555) failed with:
RuntimeError: All books failed to process. Cannot create ZIM without any content.
despite the task's own progress reporting showing 95% (254/267) done right before the failure — which reads as "it got almost all the way there, then died," but the actual error says zero books succeeded. That apparent contradiction is itself confusing to debug, on top of the underlying failure.
Root cause
open.umn.edu(Open Textbook Library's own site) started returning429 Too Many Requestson the per-book metadata endpoint (https://open.umn.edu/opentextbooks/textbooks/<id>.json), visible for books 1966/1986 in the captured log tail.core/pipeline.py'sprocess_one()wraps each book in a bareexcept Exceptionand always callsself.progress.increase_progress()regardless of outcome — so the progress counter tracks attempts, not successes. That's why 95%/254-267 isn't actually meaningful here: it's entirely possible most/all of those "done" books individually failed their metadata fetch (via repeated 429s) and simply never got added tostore.works, which is what then triggerscompute_flame_ratings's "All books failed to process".core/download_engine.py'sfetch_bytes_with_retrydoes treat429as non-fatal and retries with exponential backoff, but: (a) it doesn't honor aRetry-Afterheader if OTL sends one, and (b) there's no shared/global pacing across the pipeline's concurrent per-book workers hitting the same host — so under sustained throttling, many/most of the concurrent requests can each independently exhaust their ownmax_retry_time=30budget and fail around the same time, rather than the pipeline backing off as a whole.
Prior art in other openZIM scrapers
We already have working solutions for exactly this ("one host rate-limits us, and the fleet needs to share pacing instead of each request retrying blindly on its own") in two sibling scrapers:
- sotoki (
src/sotoki/utils/imager.py,Imager/HostData): each hostname gets its own adaptiverequest_interval_milliseconds, honored by a shared scheduling loop so all workers pace themselves against that single shared per-host clock. It explicitly parsesRetry-After(parse_retry_after_header, with a per-host exclusion list for hosts known to send bad values) to set anot_before_date, and multiplicatively slows down the per-host interval on429/503/403/524(capped at a max interval) while gradually speeding back up after sustained success. Failed downloads are requeued rather than permanently dropped, and the whole run only aborts via a global failure-ratio circuit breaker, not on transient zero-successes-so-far. - mwoffliner (
src/Downloader.ts): a single sharedDownloaderinstance centralizes backoff (exponential, 1s–60s,failAfter: 10⇒ ~6 min budget) for every request against the wiki, explicitly retrying on429/500/502/503/504/524, bounded by the overall--speed/worker-count andpageRequestIntervalsettings — i.e. one shared, centrally-paced pipeline per host rather than N independent per-request retry loops.
Suggested fix directions
- Respect
Retry-Afteron 429 responses fromfetch_bytes_with_retryinstead of just blindly exponential-backing-off (see sotoki'sparse_retry_after_header). - Shared/adaptive per-host pacing for metadata fetches, along the lines of either prior-art approach above, rather than each concurrent worker retrying independently with no awareness of the others.
- Separately: make progress reporting (or at least the final error) distinguish "attempted" from "succeeded" so a run that quietly failed every book doesn't look like it got 95% of the way there.
- Dominant language
- Python
- Stars
- 7
- Forks
- 4
- Avg merge
- 16h 45m
- Merged PRs (30d)
- 67
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openzim/papers
-
Difficulty 4/5 3-5 days Newbie friendliness 26/100
openzim/papers#223 · 1 comment ·
Maintainers usually reply within 1 day
-
pending clarification
Difficulty 4/5 3-5 days Newbie friendliness 48/100
openzim/papers#213 · 1 comment ·
Maintainers usually reply within 1 day
-
Wikisource English has only 16 booksPossibly taken @pawank925 claimed this 7 days ago. Open
openzim/papers#209 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Release 1.4.0Possibly taken @benoit74 claimed this 7 days ago. Open
openzim/papers#208 · 1 assignee ·
Maintainers usually reply within 1 day
-
Fetch BNR author bio and portraitPossibly taken @elfkuzco claimed this 14 days ago. Open
openzim/papers#179 · 3 comments · 1 reaction · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
MarkdownDocSerializer.post_process escapes '\<' to '\<', rendering literal '<' in CommonMarkOpen
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
docling-project/docling-core#1067 ·
Maintainers usually reply within 3 days
-
correction metadata
Difficulty 1/5 Under an hour Newbie friendliness 85/100
acl-org/acl-anthology#11101 · 1 comment ·
Maintainers usually reply within 1 day
-
[BUG] crewai tool create/install/login exit 0 when they failPossibly taken @Kiko0301 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
vllm-project/compressed-tensors#1033 ·
Maintainers usually reply within 3 days
-
chore kaizen ui-rewrite
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
IBM/mcp-context-forge#7681 ·
Maintainers usually reply within 2 days