Skip to content

Fix revision lookup for builds moved to the extra build directory - #14

Merged
samth merged 4 commits into
racket:masterfrom
samth:drdr-archived-build-paths
Sep 23, 2026
Merged

samth merged 4 commits into
racket:masterfrom
samth:drdr-archived-build-paths

Conversation

@samth

@samth samth commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

Pages for revisions that have aged out to the extra build directory took about 42 seconds of CPU to conclude "Not Found", and their "next change" links redirected back to the page itself, which trapped crawlers. path->revision indexed into the exploded path at the length of the primary build directory. That index is wrong for the shorter extra root, and archive lookups stripped a root prefix without checking it.

Each commit can be reviewed on its own:

  1. Add path-prefix-split, a helper with tests.
  2. Make archive lookups compare the root prefix they strip, and add #:base so callers can name the build's current directory. Primary builds behave as before.
  3. Fix path->revision for both build roots. This is the actual fix.
  4. Make archive-repair pass #:base, so it works for moved builds.

On hurin I compared the patched renderer against the deployed one. Live pages are identical. An archived file page (55390 rss.xml) now renders in 0.14–0.26s instead of showing "Not Found" after 4–5s (with a warm cache), and next-change for it redirects to 55400 instead of looping.

The exception-reporting changes that used to be in this PR are now in a separate PR stacked on this one. The scrub, log-baseline and Cloudflare-IP changes are in three independent PRs.

@samth
samth force-pushed the drdr-archived-build-paths branch from 011aa28 to fcfa33c Compare August 17, 2026 12:36
Callers that move a path between build roots explode both paths, compare
the first elements, and strip them. This helper does that once, and the
next commits use it.
An archive records the root its build had when the archive was created.
`archive-extract-path` dropped as many leading elements from a query as
that root has, without comparing them, so a query under any other root
of the same length resolved to an entry at the wrong level. A build that
has aged out to the extra build directory lives under such a root.

Compare the prefix instead, and add a `#:base` argument so that a caller
that knows where the build lives now can say so. cache.rkt passes the
build's current directory.

Primary builds behave as before. Archived builds still fail, as they do
today, because `path->revision` cannot parse their paths; the next commit
fixes that.
`path->revision` indexed into an exploded path at the length of the
primary build directory. Builds that have aged out live under the extra
build directory, which is one element shorter in production, so the index
landed on "logs" and `string->number` returned #f, breaking the function's
contract. `cached-directory-exists?` caught that exception and reported
the build as absent, so `find-previous-rev` walked backwards one revision
at a time, and every other archive lookup during a render failed the same
way. A page for an archived revision spent about 42 seconds of CPU to
conclude "Not Found"; with this change it renders in about 0.2 seconds.

Because every file page links to "next change" for its revision, those
pages also trapped crawlers: for an archived revision the link redirected
back to the page itself.

Match a root prefix against either build directory instead.
archive-repair looked up a build's current directory inside its archive,
but the archive names its contents by the directory the build had when
the archive was created. For a build that has moved to the extra build
directory the two differ, and the repair failed. Pass the current
directory as `#:base`.
@samth
samth force-pushed the drdr-archived-build-paths branch from fcfa33c to 2cdaead Compare September 23, 2026 20:01
@samth
samth merged commit 2a5b46c into racket:master Sep 23, 2026
1 check passed
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