Skip to content

Count a capped expand's children as stopAdmitting counts its remainder - #394

Merged
TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
bfs2021:fix/capped-skipped-excluded
Nov 17, 2026
Merged

TMHSDigital merged 1 commit into
TMHSDigital:mainfrom
bfs2021:fix/capped-skipped-excluded

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Problem

A recursive scan that has already reached its -max-queries budget counted every child of a parent found after the cap as skipped. Children that -exclude rules out were reported as skipped instead of excluded, and, with multi-label entries, children already reached from another parent were counted again. The -stats and run-quality report then overstate skipped and understate excluded, and a resumed run inherits the wrong split.

Root cause

expand's case d.capped: branch added all n children of the late parent to skipped unconditionally. The other counting path, stopAdmitting, has counted its remainder exactly since #361: countUnbuilt places children an exact pattern or an excluded subtree rules out under excluded, and the multi-label paths drop names the visited set says were already reached. A parent that resolves after the cap bypassed all of that, so the two paths disagreed on the same kind of name.

Fix

Queue the late parent as a temporary expansion (with remaining raised by n, as the uncapped branch does) and call stopAdmitting again. It counts the one new expansion with the machinery #361 introduced: the O(1) fast path when there is no visited set and no -exclude, countUnbuilt for single-label entries, countUnbuiltRepeats for multi-label entries without exclusions, and the exact walk otherwise. Excluded children go to excluded, visited ones are not counted twice, and tested plus skipped plus excluded still adds up to every candidate. Tested plus skipped plus excluded still equals every candidate, and the existing capped-expand behaviors (d.skipped += d.n with no exclusions, the whole-subtree-excluded case) are unchanged.

Testing

  • TestCappedExpandCountsExcludedChildren: a capped recursive scan with an exact -exclude pattern expands a late parent; its excluded child lands in excluded and the rest in skipped (failed before the fix: all ten children went to skipped).
  • TestCappedExpandCountsRecursiveRepeatsOnce: two parents resolve after the cap and reach x.a.b.example.com from both sides, with and without an exact pattern; admitted plus skipped plus excluded equals the candidates the uncapped scan generates, and the excluded name is excluded whichever parent reaches it (failed before the fix: counted twice, and as skipped).
  • Full go test -shuffle=on ./... passes, go vet and gofmt are clean.

TMHSDigital#393)

A recursive scan that has reached -max-queries counted every child of a
parent found after the cap as skipped: expand's capped branch added all
n children to skipped without checking -exclude or the visited set, so
excluded children were misreported as skipped and, with multi-label
entries, children already reached from another parent were counted
twice. TMHSDigital#361 made stopAdmitting count the queued remainder exactly; a
late parent now goes through the same split by queueing a temporary
expansion and stopping admission again, so excluded children are
excluded and visited ones are not counted twice.
@TMHSDigital
TMHSDigital merged commit bdaf171 into TMHSDigital:main Nov 17, 2026
17 checks 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.

2 participants