Skip to content

backup: clean partial scan cache on create failure - #2288

Open
ousamabenyounes wants to merge 3 commits into
PlakarKorp:mainfrom
ousamabenyounes:fix/issue-2254-cache-full
Open

backup: clean partial scan cache on create failure#2288
ousamabenyounes wants to merge 3 commits into
PlakarKorp:mainfrom
ousamabenyounes:fix/issue-2254-cache-full

Conversation

@ousamabenyounes

Copy link
Copy Markdown
Contributor

Summary

  • generate the backup snapshot ID before calling snapshot.Create so Plakar can identify the scan cache path for that attempt
  • remove only that partial scan cache directory if snapshot creation fails before returning a builder
  • add a regression test covering a scan cache constructor that leaves a partial directory before failing

Testing

  • RED before fix: go test ./subcommands/backup -run TestBackupCleansPartialScanCacheOnCreateFailure -count=1 failed because the partial scan cache directory remained
  • GREEN after fix: go test ./subcommands/backup -run TestBackupCleansPartialScanCacheOnCreateFailure -count=1
  • go test ./subcommands/backup -count=1
  • go test ./subcommands/pkg -count=1 && go test ./subcommands/backup -count=1
  • local full runner on patched branch: go build -v ./..., go test -v -p 4 -coverprofile=coverage.out -covermode=atomic -timeout 2m ./..., GOOS=windows GOARCH=amd64 go build -v .

Refs #2254

@omar-polo omar-polo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but aren't we already removing the packfile directory a few lines above (see backup.go:298) so how is this changing anything?

(also, it's not really a scan cache, that's something we don't really have anymore, but rather the storage for packfiles that are in the process of being created)

@ousamabenyounes
ousamabenyounes force-pushed the fix/issue-2254-cache-full branch from 8e747b5 to a4d0ff5 Compare July 31, 2026 08:58
@ousamabenyounes

ousamabenyounes commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Sorry for the delayed reply, and thanks for the review.

You're right that this PR doesn't fix #2254 as reported. Line 298 removes
PackfileTempStorage, while this PR removes what kloset still calls the
ScanCache — happy to use whatever term you prefer for it.

The current Plakar workaround duplicates kloset's internal path and only cleans
the new failed attempt. It won't recover the large workspace orphaned by an
earlier interrupted backup.

I think this needs two separate changes:

  1. Error-path cleanup in kloset: Create, CreateWithRepositoryWriter and
    Fork can return after newBuilder without closing the ScanCache, so
    DeleteOnClose never fires (checked against 9310b71, the revision in go.mod).
    Small and self-contained, but it only covers empty workspaces.
  2. Stale-workspace recovery for [Bug]: Plakar backup fails when cache drive is full #2254 itself, which has to stay safe with
    concurrent backups. That's a design question, not a patch.

I'll close this PR unless you'd prefer to keep it as limited hardening. Happy to
send the kloset error-path PR straight away; for the recovery side I'd rather
agree on the shape first.

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