Skip to content

Write faulted objects off the async worker - #45

Open
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/fault-writes-off-the-worker
Open

Write faulted objects off the async worker#45
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/fault-writes-off-the-worker

Conversation

@0bserver07

Copy link
Copy Markdown
Contributor

crates/walgit-server/src/web/objects.rs read objects from the remote pack set asynchronously and then wrote them to the loose store on the same tokio worker: fault_many called write_local for every object after its join_all, and fault did the same for one. write_local goes to LocalRepo::write_loose_object, which stats a path, deflates the object and creates and renames a file, so a commit diff of up to MAX_DIFF_OBJECTS objects could hold a runtime thread for seconds on a remotely served monorepo. Principle VI again.

fault_many now collects each chunk of 32 reads and hands the batch to one tokio::task::spawn_blocking that does the writes, and fault goes through the same helper. Same objects written, already faulted ids still skipped, same error text, a join failure becomes an internal error; MAX_DIFF_OBJECTS, the read side and the loose store in walgit-git are untouched. One difference on the failure path only: a read error partway through a chunk now returns before that chunk's earlier objects are written, which only affects a cache.

Checked with cargo clippy -p walgit-server --all-targets --no-deps -- -D warnings, cargo test -p walgit-server --test web_api --test web_ui --test api_v1 (the remote-objects conformance test lives in web_api), the e2e remote tests and blocking_work_in_the_install_path_does_not_stall_requests, and cargo fmt --all -- --check.

The web object faulter read objects from a remote pack set asynchronously
and then called `write_loose_object` for each of them on the same tokio
worker, so one request for a commit diff could spend seconds stating paths,
deflating and renaming files while it held a runtime thread. `fault_many`
now collects the reads of each chunk of 32 and hands the whole chunk to one
`tokio::task::spawn_blocking`, and `fault` writes its single object through
the same helper. Behaviour is unchanged: the same objects land in the loose
store, ids already faulted are still skipped, and the error text is still
`fault object <oid>: <e>`, with a join failure reported as an internal
error. AGENTS.md principle VI says never block the async runtime, and
`spawn_blocking` is the pattern the rest of the crate already uses. Checked
with `cargo clippy -p walgit-server --all-targets --no-deps` (clean apart
from the pre-existing `rebuild.rs:141` cast lint), the `web_api`, `web_ui`
and `api_v1` suites, `cargo test -p walgit-server --test e2e -- remote`,
the e2e `blocking_work_in_the_install_path_does_not_stall_requests`, and
`cargo fmt --all -- --check`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CSbhRh6UEjFrgBYYzucvDe
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.

1 participant