Repository navigation
Create the search index explicitly instead of on Django startup - #562
Merged
Merged
Conversation
MwmblConfig.ready() created the search index whenever it was missing, so a data volume that failed to mount gave a server running on an empty index, and every process that set Django up wrote one - including a plain import of mwmbl.crawl (400MB). - ready() now creates only the external cache, which is disposable. - New `manage.py create_index` command, run by `make install` (`make create-index`). - search_setup refuses to start on a missing index or one whose shape disagrees with NUM_PAGES, keeping the protection ready() gave the production index. - The crawler's main() creates its own index, so volunteers still need no setup step. - Tests create theirs in pytest_sessionstart. - CRAWLER_VERSION 1.0.1, since the crawler's startup changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
The URL check imports search_setup, which now fails when the index is missing, so the command died before it could create the index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DTbu4qL49ukb9EUc7Fn9fg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #561. Merge that first; this PR will then retarget to
main.What changed
ready():MwmblConfig.ready()no longer creates the search index. It still creates and resizes the external cache, which is disposable and depends on rebuilding at boot.manage.py create_indexcreates the search index if it's missing and checks the shape of an existing one.make installnow runs it through a newmake create-indextarget.search_setup.py(where the server opens the index) refuses to start if the index is missing, with a message pointing at the command. It also refuses if the index's shape doesn't matchNUM_PAGES. That keeps the protectionready()used to give the production index. The shape check is factored out asindex_shape_mismatch()and shared withcreate_index().main()creates its own index, so volunteers still need no setup step.pytest_sessionstart, before collection importssearch_setup.CRAWLER_VERSIONgoes to 1.0.1, sincecrawl.pyandapps.pyare crawler code.Why
Creating the index on startup had two problems:
import mwmbl.crawl, which wrote 400MB. That import now writes only the 11MB external cache.Deploying
manage.py create_indexrun once. Without it, the server fails at startup and the healthcheck fails the deploy.devdata/index-v2.tinysearch. New ones get it frommake install.Verification
/tmp/test_mwmbl_data: 1646 passed, 9 skipped.test/test_create_index_command.pycheck three things:ready()creates the external cache but not the search index;main()creates its index before it starts crawling.make checkpasses.python -c "from mwmbl.crawl import run"with a freshHOME) now leaves onlyexternal-cache.tinysearchbehind.search_setup.py. They run at module import, which the test session has already done.🤖 Generated with Claude Code