Skip to content

Cancelling a crawl mid delayed-type-check orphans .delayed placeholders#496

Merged
xroche merged 3 commits into
masterfrom
fix-483-delayed-orphan
Jul 5, 2026
Merged

Cancelling a crawl mid delayed-type-check orphans .delayed placeholders#496
xroche merged 3 commits into
masterfrom
fix-483-delayed-orphan

Conversation

@xroche

@xroche xroche commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Cancelling a crawl mid delayed-type-check leaves X.N.delayed partials in the mirror (#483): hts_wait_delayed() patches url_sav to the final name while the transfer can still be writing to the placeholder path, and every cleanup keyed on IS_DELAYED_EXT(url_sav) then misses the file. Fix: back_delayed_rename() moves the placeholder to the final name right before the patch; the cache-miss re-add path discards its placeholder when a cancel drops the last reference.

The .delayed leftover audit now runs for every local crawl, and the new 39_local-delayed-cancel test pins the scenario (timing-dependent: 4/10 failing on master, 10/10 clean here; 0 orphans in 35 harness crawls vs about 1 in 6 before).

Closes #483.

xroche and others added 3 commits July 5, 2026 17:42
hts_wait_delayed() patches url_sav to the final name while a
direct-to-disk transfer may still be writing to the .delayed placeholder
path (bound when a back_wait tick lands between the slot's unlock and
the patch, e.g. url_savename's post-stop test branch pumping sockets).
From then on every cleanup keyed on IS_DELAYED_EXT(url_sav) is blind to
the on-disk name and a cancelled mirror leaves X.N.delayed partials
behind (#483).

Move the placeholder to the final name right before the patch
(back_delayed_rename, reopening a mid-transfer stream in append mode),
and drop it in the cache-miss re-add path where a cancel between
back_maydelete() and the re-add dropped its last reference.

The .delayed leftover audit in local-crawl.sh now runs for every crawl
(--skip-delayed-audit is gone), and 39_local-delayed-cancel exercises
the cancel window: 4/10 runs failing on master, 10/10 clean with the
fix; 0 orphans in 35 direct-harness cancelled crawls against ~1 in 6
before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
Windows rename() fails when the target exists; unlinking newname there
would destroy a previous run's completed file during an update crawl.
Drop only what the slot owns: the placeholder if the rename failed, the
moved partial if the reopen did.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Xavier Roche <roche@httrack.com>
@xroche xroche merged commit 7928db5 into master Jul 5, 2026
15 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.

Cancelling a crawl mid delayed-type-check orphans .delayed placeholder files

1 participant