fix(library): a scan and a duplicate-resolver pass never touch the files at once (#8197)
release / go (push) Successful in 2m17s
release / web (push) Successful in 1m29s
release / govulncheck (push) Successful in 20s
release / integration (push) Successful in 4m28s
release / android (push) Successful in 4m25s
release / Build signed APK (push) Successful in 5m8s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 15s
release / Verify release artifacts (tag releases only) (push) Skipped

The resolver checked for a running scan once, at the start of a pass. At
boot that check could run before the startup scan recorded its run, and a
scan that began mid-pass was never seen, so the pass removed copies the
scan had listed (23 "no such file" errors on dev, 2026-11-28).

A gate now keeps the two apart for their whole length: a full scan and
each watcher batch hold it, a scan that meets a pass waits for it (up to
30 minutes, then gives up with a named error), and a pass that meets a
scan is put off and tried again a minute later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 17:28:52 -05:00
co-authored by Claude Opus 5.5
parent 7c6c47cdb2
commit 05e087268a
5 changed files with 189 additions and 4 deletions
+9 -3
View File
@@ -593,9 +593,8 @@ func (w *DuplicateResolveWorker) tickOnce(ctx context.Context) (waitForScan bool
}
return false
}
// A scan in flight has listed the files it will reconcile: a copy removed
// now is marked present again when it does. A run past StuckScanThreshold
// is a dead one.
// A pass waits out a whole scan run, whose later stages re-read files
// too. A run past StuckScanThreshold is a dead one.
running, err := scanRunning(ctx, q)
switch {
case err != nil:
@@ -606,6 +605,13 @@ func (w *DuplicateResolveWorker) tickOnce(ctx context.Context) (waitForScan bool
case running:
return true
}
// A run can begin after the check above, and a watcher batch has no run
// at all: filesGate keeps either from reading files while this pass
// removes them.
if !filesGate.tryAcquire() {
return true
}
defer filesGate.release()
res, err := ResolveDuplicatesWith(ctx, w.pool, w.logger, w.dataDir, w.settings.Get().AutoResolve, w.src)
if err != nil && ctx.Err() == nil {
w.logger.Warn("duplicate resolve: pass failed", "err", err)