fix(s3): delete unused blocks with bounded concurrency - #315
fix(s3): delete unused blocks with bounded concurrency#315christophersherman wants to merge 1 commit into
Conversation
Signed-off-by: Christopher Robert Sherman <csherman@mailbox.org>
|
@mantissahz This is the deletion-phase follow-up discussed on backupstore#313 for the priority/0 longhorn/longhorn#8060 path. It is independent of #313 and keeps GCS compatibility by using bounded individual DCO is green, and the PR includes exact request-count tests, focused race coverage, bounded 65,536-key batching, an eight-worker concurrency test, and comparative benchmark results. Could you help route maintainer review and the upstream |
There was a problem hiding this comment.
Pull request overview
Adds efficient, bounded-concurrency S3 block garbage collection while preserving fallback behavior for other drivers.
Changes:
- Introduces batched exact-file removal.
- Adds concurrent exact-key S3 deletion with bounded errors.
- Covers volume and backing-image cleanup behavior comprehensively.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
s3/s3.go |
Implements bounded concurrent removal. |
s3/s3_service.go |
Adds exact DeleteObject handling. |
s3/s3_remove_test.go |
Tests S3 removal behavior. |
exact_file_remover.go |
Defines batching capability. |
exact_file_remover_test.go |
Tests batching and errors. |
deltablock.go |
Uses exact removal for volume GC. |
deltablock_cleanup_test.go |
Tests volume cleanup paths. |
backupbackingimage/backupbackingimage.go |
Uses exact removal for backing-image GC. |
backupbackingimage/cleanup_test.go |
Tests backing-image cleanup paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Which issue(s) this PR fixes:
Issue longhorn/longhorn#8060
What this PR does / why we need it:
Block GC already knows the exact object path for every unreferenced block. However, the S3 driver's existing
Removemethod treats each path as a prefix: it issuesListObjectsV2, creates another SDK client, and then callsDeleteObject. GC repeats that sequence serially for every unused block.This PR adds an optional
ExactFileRemovercapability and uses it for volume-backup and backing-image block GC:DeleteObjectrequests without a preceding LIST.NoSuchKeyas an idempotent success.Removefallback for all drivers that do not opt in.BlockCountunchanged if any deletion fails.For
Nunused S3 blocks, this changes the deletion phase from approximatelyNprefix LISTs plusNserial DELETEs toNbounded-concurrent DELETEs. It does not change reference discovery or lock safety.Synthetic benchmark: 100 exact deletions with 1 ms fake request latency, Apple M1 Max, three iterations:
This is about 7.7x lower elapsed time in the latency-bound deletion phase. The HTTP regression test separately verifies exactly one DELETE per path and no LIST or multi-object-delete request.
Special notes for your reviewer:
This deliberately does not use the S3 Multi-Object Delete API. Longhorn removed that path in backupstore#41 because Google Cloud Storage's S3 interoperability rejected it (longhorn/longhorn#1404). The implementation uses concurrent individual
DeleteObjectcalls instead.This is independent of and complementary to backupstore#313:
Deletion locks of the same type can overlap. The limit is therefore eight requests per GC operation, not a global rate limit. Coalescing duplicate GCs, changing lock scope, and optimizing retained-manifest scanning remain separate work.
Regression coverage includes:
NoSuchBucketValidation:
-race: passgo test -race ./backupbackingimage: passgo test -race ./s3: pass./...: passgo vet ./...: passgolangci-lint run ./...: 0 issuesThe repository's current
scripts/testomits root-package tests, so the new root cleanup tests were invoked explicitly. The full pre-existing root suite also has the unrelatedTestInspectBackupfailure described by #313; this change does not modify that path.Additional documentation or context
Historical review precedent already recommended a fixed worker pool and noted that
DeleteObjectscould benefit from parallel deletion: backupstore#63.