Skip to content

Multi-wacz upload processing - #3323

Open
emma-sg wants to merge 54 commits into
mainfrom
issue-2814-multi-wacz-upload
Open

Multi-wacz upload processing#3323
emma-sg wants to merge 54 commits into
mainfrom
issue-2814-multi-wacz-upload

Conversation

@emma-sg

@emma-sg emma-sg commented May 20, 2026

Copy link
Copy Markdown
Member

Closes #2814

Changes

This adds an upload post-processing stage that runs after an item is uploaded, either in the same request as the upload if the file is <50MiB or in a background job if the file is larger.

This step inspects the WACZ file and if it find it's a nested file (with multiple WACZ files inside it), it expands the nested WACZs into separate files that are attached to the archived item. This also allows for pages to be correctly ingested for nested uploaded items.

The upload completion webhook is sent after this processing completes, so for larger uploads webhooks may send later than they previously would have.

Also adds a new "upload-processing" archived item state, which displays in most places on the frontend the same way as "uploaded" does, but with a pulsing dot icon & a loading indicator for the page count.

I made the deliberate choice here not to include processing uploads in the archived item selector dialog window for collections, since I believe the page calculation there relies on the archived items being correctly split/having pages in the DB by then.

Testing

The backend changes here are pretty thoroughly integration-tested.

To test manually:

  1. Upload a small multi-wacz file (there's one in the test data files), and check that the page count is correct after uploading. This shouldn't show a separate "upload processing" state.
  2. Upload a larger multi-wacz file (you can grab one from one of the collections on dev if you like), and check that it shows up after uploading with an "upload processing" state. When this completes, check that the page count is correct.

@emma-sg
emma-sg force-pushed the issue-2814-multi-wacz-upload branch 3 times, most recently from 417e564 to 8822375 Compare June 17, 2026 14:31
@emma-sg
emma-sg force-pushed the issue-2814-multi-wacz-upload branch 4 times, most recently from 89e579b to a88251b Compare June 23, 2026 19:34
@emma-sg
emma-sg requested review from ikreymer and tw4l June 23, 2026 20:29
@emma-sg
emma-sg marked this pull request as ready for review June 23, 2026 20:29
@emma-sg
emma-sg force-pushed the issue-2814-multi-wacz-upload branch from a88251b to 548e84d Compare June 24, 2026 16:45
@emma-sg
emma-sg force-pushed the issue-2814-multi-wacz-upload branch 2 times, most recently from b680d69 to d952a61 Compare July 6, 2026 18:07

@mistydemeo mistydemeo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Gave it a test and it's working well. UI works nicely too.

Comment thread backend/btrixcloud/background_jobs.py
Comment thread backend/btrixcloud/background_jobs.py
Comment thread backend/btrixcloud/background_jobs.py
Comment thread backend/btrixcloud/uploads.py
@emma-sg
emma-sg requested a review from tw4l July 8, 2026 00:42
Comment thread backend/btrixcloud/uploads.py Outdated
Comment thread backend/btrixcloud/uploads.py Outdated
@emma-sg
emma-sg force-pushed the issue-2814-multi-wacz-upload branch from 69e5314 to 0bee994 Compare July 8, 2026 20:29
@ikreymer ikreymer added this to the 1.24 Release milestone Jul 8, 2026

@tw4l tw4l left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still testing (especially with large multi-waczs) on dev, but looking great so far! Just left a few comments here.

Comment thread backend/btrixcloud/uploads.py Outdated
Comment thread backend/btrixcloud/uploads.py Outdated
Comment thread backend/test/test_uploads.py Outdated
Comment thread backend/test/test_uploads.py
Comment thread backend/test/test_uploads.py
@emma-sg
emma-sg marked this pull request as draft July 9, 2026 19:27
Comment thread backend/btrixcloud/uploads.py Outdated
@tw4l

tw4l commented Jul 9, 2026

Copy link
Copy Markdown
Member

I made the deliberate choice here not to include processing uploads in the archived item selector dialog window for collections, since I believe the page calculation there relies on the archived items being correctly split/having pages in the DB by then.

I think this is the right choice, and that the backend API will already reject attempting to add these items to a collection anyway since they are not yet in a successful state until postprocessing completes anyway.

@ikreymer ikreymer removed this from the 1.24 Release milestone Jul 10, 2026
@emma-sg
emma-sg marked this pull request as ready for review July 13, 2026 18:03
@emma-sg
emma-sg force-pushed the issue-2814-multi-wacz-upload branch from 1bd6cda to b28bba3 Compare July 13, 2026 18:10
@emma-sg
emma-sg marked this pull request as draft July 13, 2026 18:43
@emma-sg

emma-sg commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

I think maybe it makes sense to review this separately from the upload speedup changes that are in progress, since they're not really related changes. Should definitely get both in for the same release though! Marking as ready for review.

@emma-sg
emma-sg marked this pull request as ready for review July 13, 2026 21:00
emma-sg and others added 24 commits August 6, 2026 17:10
- bare `raise` re-raises caught exception, so no need for `raise e`
- variable casing fix

Co-authored-by: Misty De Meo <mistydemeo@gmail.com>
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
this ended up being a bit more in-depth than i first thought, since we
need to keep track of the particular file being processed in a list of
pre-existing files and replace only the processed file in that list,
rather than the whole file
- adds concurrency limit for multi-WACZ file splitting
- refactors the database updates to use atomic $pull/$push/$inc
  operations
- makes cleanup best-effort to avoid blocking uploads
mongodb throws an error (`ConflictingUpdateOperators`) if you have both
a push and a pull in the same operation
deleting

when an upload is deleted during post-processing, it gets marked as
deleted in the db and aborts further processing
also removes unnecessary `upsert=True` on status updates where the
document should already exist
updates `ensure_cron_cleanup_jobs_exist` to instead be generic for
various cron jobs
@emma-sg emma-sg reopened this Aug 6, 2026
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.

WACZ-files dowloaded from Browsertrix and then uploaded to Browsertrix using "Upload WACZ" contains 0 pages

4 participants