Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add endpoints to read pages from older crawl WACZs into database #1562

Merged
merged 15 commits into from Mar 19, 2024

Conversation

tw4l
Copy link
Contributor

@tw4l tw4l commented Feb 28, 2024

Fixes #1597

New endpoints (replacing old migration) to re-add crawl pages to db from WACZs.

After a few implementation attempts, we settled on using remotezip to handle parsing of the zip files and streaming their contents line-by-line for pages. I've also modified the sync log streaming to use remotezip as well, which allows us to remove our own zip module and let remotezip handle the complexity of parsing zip files.

Database inserts for pages from WACZs are batched 100 at a time to help speed up the endpoint, and the task is kicked off using asyncio.create_task so as not to block before giving a response.

StorageOps now contains a method for streaming the bytes of any file in a remote WACZ, requiring only the presigned URL for the WACZ and the name of the file to stream.

@tw4l tw4l requested a review from ikreymer February 28, 2024 22:43
@tw4l tw4l marked this pull request as draft February 29, 2024 19:28
@tw4l tw4l force-pushed the crawl-pages-oom branch 2 times, most recently from 7ea1272 to 89d34db Compare March 5, 2024 21:38
@tw4l tw4l changed the title Await adding pages from crawls one at a time Add migration to read pages from older crawl WACZs into database Mar 5, 2024
@tw4l tw4l marked this pull request as ready for review March 5, 2024 22:40
@tw4l
Copy link
Contributor Author

tw4l commented Mar 5, 2024

@ikreymer This is ready for re-review, now with remotezip. I also switched log streaming to use remotezip, so was able to remove our whole local zip module. I've done some local testing with the following results:

  1. Crawl log streaming from WACZ files is working once crawl finishes (nightly test also passes)
  2. Migration is working in local testing
  3. Memory usage doesn't seem to increase during either 1 or 2, I think we have the streaming working properly now

@tw4l tw4l changed the title Add migration to read pages from older crawl WACZs into database Add endpoints to read pages from older crawl WACZs into database Mar 7, 2024
@tw4l tw4l force-pushed the crawl-pages-oom branch 2 times, most recently from 298b8ab to ac81831 Compare March 14, 2024 16:44
@ikreymer ikreymer merged commit 21ae383 into main Mar 19, 2024
4 checks passed
@ikreymer ikreymer deleted the crawl-pages-oom branch March 19, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add method of populating pages for older crawls
2 participants