Skip to content

test(locallibrary): stop reading a cancelled upload until publishing stops - #317

Merged
botandbang merged 1 commit into
mainfrom
bnb/upload-cancel-signal
Oct 30, 2026
Merged

botandbang merged 1 commit into
mainfrom
bnb/upload-cancel-signal

Conversation

@botandbang

Copy link
Copy Markdown
Contributor

What and why

The upload-cancel test still failed under load after #278. Its server read 8 KiB every 10 ms, and the test gave the server 10 s to see the connection close. The host stops sending at its next chunk once the cancel reaches it. But what it sent before the cancel still sits in the socket buffers (0.7 to 1 MB here, up to several MiB with macOS autotuning), and at that read rate draining it took 1.4 s on an idle machine and more than 10 s under load. A 15x slower server reproduces the timeout.

Reading at full speed isn't enough on its own: the cancel goes from the host to the plugin and back to the host's net/fetch before the upload sees it, and under load a fast server takes the whole 32 MiB before then.

Now the server reads once, cancels, and reads nothing more until publishing has returned. Until then the host can only fill the buffers. Then it reads the rest at once, stopping at EOF or the full size, and the test joins it for the byte count. That works because the plugin passes the cancel on to its net/fetch before it answers the hook, so by the time publishing returns the upload has been told to stop. The 10 s eventually, the per-read sleep, and the two atomics are gone.

Fixes LOC-108

How it was tested

  • cargo fmt --check, and cargo clippy -p locallibrary --all-targets -- -D warnings.
  • cargo nextest run -p locallibrary --test it --retries 0 on plugins::destinations::: 11 pass.
  • 50 runs in a row under 45 busy loops, and 50 more beside the other 196 plugins:: tests at --test-threads 8 (load 60 to 112): all passed, with at most 680 KB of the 32 MiB read. The 196 passed too.
  • With the upload's cancel check removed, it fails in 0.5 s saying all 32 MiB were sent. With a 100 ms sleep injected into the host's Sending::read, it passes in 1.4 s.
  • Not run: the full suite and Windows clippy.

Checklist

  • Tests cover the change

@botandbang
botandbang requested a review from bnb as a code owner October 30, 2026 16:17
@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

LOC-108

@botandbang
botandbang enabled auto-merge October 30, 2026 16:31
@github-actions github-actions Bot added locallibrary locallibrary and the loclib-* crates locallibrary: core The core crate, the data model and rekordbox's formats locallibrary: plugins The plugin protocol, its host and the built-in plugins tests Tests, fixtures and test harnesses labels Oct 30, 2026
@github-actions

Copy link
Copy Markdown

Rust coverage

From run 562. Both are held to the thresholds in .cargo/config.toml.

Tests Lines Functions Regions
All 97.46% (81787/83922) 96.57% (13034/13497) 95.76% (179825/187793)
Hegel property tests alone 95.2% (79893/83922) 93.75% (12653/13497) 93.3% (175216/187793)

@botandbang
botandbang merged commit 0b16743 into main Oct 30, 2026
66 checks passed
@botandbang
botandbang deleted the bnb/upload-cancel-signal branch October 30, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

locallibrary: core The core crate, the data model and rekordbox's formats locallibrary: plugins The plugin protocol, its host and the built-in plugins locallibrary locallibrary and the loclib-* crates tests Tests, fixtures and test harnesses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants