diff --git a/Plans/10 Distribution/S048-server-farms.md b/Plans/10 Distribution/S048-server-farms.md new file mode 100644 index 0000000..790d252 --- /dev/null +++ b/Plans/10 Distribution/S048-server-farms.md @@ -0,0 +1,30 @@ +# S048 — Servers behind a load balancer with different validators + +> Category 10 Distribution · Model: Opus (engine correctness, never mix two files) · Effort: medium · Depends on: S046 · Phase: test · Human: 🧑 yes before release +> Files touched: crates/core/src/http/{mod,fetch,download,parts}.rs, crates/testserver/**, crates/core/tests/**, docs/tests/S048-server-farms.md, docs/releases/0.1.1.md + +## Goal +Downloads from romsgames.net (and any site with a server farm) fail at once with "File changed on the server". Seen on 2026-11-26 with four 1-byte range requests to the same link (`static.romsgames.net/.../output.bin?token`): + +| range | Server | Last-Modified | ETag | Content-Range total | +|---|---|---|---|---| +| 0-0 | nginx/1.22.0 | Mon, 21 Jul 2025 20:20:29 | W/"bd6dcd82-1982ea51dc7" | 3178089858 | +| 1000000-1000000 | nginx/1.24.0 (Ubuntu) | Sun, 05 Jan 2020 05:35:27 | W/"bd6dcd82-16f743377f5" | 3178089858 | +| 0-0 | nginx/1.24.0 (Ubuntu) | Mon, 21 Jul 2025 20:20:29 | W/"bd6dcd82-1982ea51dc7" | 3178089858 | +| 2000000000-… | nginx/1.24.0 (Ubuntu) | Mon, 21 Jul 2025 20:20:29 | W/"bd6dcd82-1982ea51dc7" | 3178089858 | + +All 206, same size, same type; nodes differ only in mtime (nginx ETag = `"-"`). `Validators::same_file` (http/mod.rs) and `send_range` (fetch.rs ~159) call that `Changed`. The user's task 8 failed after 32 KB. + +## Rule (never mix two files) +When a reply's validators differ from the known ones but the total size is equal: do not fail. Check bytes instead: compare a sample of bytes already on disk with the same range from this reply (the existing `same_bytes` path in fetch.rs ~205; make the sample big enough, e.g. 64 KiB or what is there) before writing. Bytes equal → mark the task's link as a *farm* (validators unreliable): from then on compare size + byte samples only, send no `If-Range` (a Last-Modified `If-Range` makes other nodes answer 200 full), keep the first validators for display. Bytes differ, or size differs → `Changed` as today. A 200 to a range on a farm is `RangeIgnored`, not `Changed`. Also nginx-style ETags that differ only after the size part count as "maybe the same file" (still checked by bytes). + +## Steps +- [ ] testserver: a farm mode (several "nodes" with the same bytes but different Last-Modified/ETag picked per request, nginx-style weak ETags), and a liar mode (same size, different bytes) — docs in the lib.rs header +- [ ] Engine: the rule above, in probe, parts and resume; the farm flag stored with the task (store migration) so a restart keeps it; parts on a farm still run in parallel +- [ ] Tests: farm download with 4 parts completes with the right hash; pause/restart/resume on a farm; liar same-size-different-bytes still fails with Changed and keeps what is there; If-Range not sent on a farm; unit tests for the ETag comparison +- [ ] Full workspace suite once (absolute TMPDIR), release build, hidden smoke against testserver farm on a spare port (the user's Medlar 0.1.1 runs on 17616: never stop it) +- [ ] `tools/package.sh` (0.1.1, rebuilds dist/), copy the four files to `~/Projects/Medlar/dist/` as well; notes in docs/releases/0.1.1.md +- [ ] Test file with Results, PROGRESS, tick INDEX, commit `S048: …`, `git push origin HEAD` + +## Pitfalls +Never contact romsgames.net or any real site in tests; testserver only. Never weaken the "two files are never mixed" guarantee. diff --git a/Plans/INDEX.md b/Plans/INDEX.md index 0060088..7d38a9a 100644 --- a/Plans/INDEX.md +++ b/Plans/INDEX.md @@ -68,6 +68,7 @@ Tracker: https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H - [x] [S045](10%20Distribution/S045-installer-arch.md) installer.sh and Arch package - [x] [S046](10%20Distribution/S046-fixes-0.1.1.md) 0.1.1: names from the server, raise on arrival, copy in fields - [ ] [S047](10%20Distribution/S047-close-to-tray-wayland.md) Close to tray that works on Wayland +- [ ] [S048](10%20Distribution/S048-server-farms.md) Servers behind a load balancer with different validators ## Later (after version 1; not run by /orchestrate)