Skip to content

Batch conditional CAS GC blob deletes on S3 - #2534

Open
k-morozov wants to merge 59 commits into
antalya-26.8from
cas_batch_deletes
Open

k-morozov wants to merge 59 commits into
antalya-26.8from
cas_batch_deletes

Conversation

@k-morozov

@k-morozov k-morozov commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

CAS garbage collection on S3 previously sent one DeleteObject request per blob it reclaimed. When the GC fold confirms that an unreferenced blob still matches its deletion intent, it passes the ETag from that blob’s HEAD response to pending_deletes. GC groups those blobs by shard and sends a bounded DeleteObjects request with a separate ETag condition for each key. If a writer replaces a blob after the fold, the condition preserves the replacement. Once the body deletes succeed, GC removes the blob-intents/ keys selected by the fold in separate write-once requests.

The mount probe enables conditional batching after checking that matching objects are removed, a stale token preserves a replacement, and an already absent key is reported as Gone. If the store rejects the entire conditional DeleteObjects probe request with NotImplemented, the pool opens with a one-key limit for conditional deletes and keeps the configured GC I/O concurrency. A request-level InvalidRequest or InvalidArgument fails the writable mount with the original S3 error. If the S3 disk’s objects_chunk_size_to_delete limit drops below the size of a prepared chunk, GC fails the round with LIMIT_EXCEEDED before sending that chunk.

For a complete S3 response, GC keeps each key’s result in request order. When the remaining errors are retryable, such as SlowDown, GC resends only the affected keys with their original ETag values. If any key reports a delete marker, GC stops the round with CAS_DELETE_MARKER and names the key, even when another key returns SlowDown. CAS requires an S3 bucket where versioning has never been enabled. With versioning Enabled or Suspended, a delete can create a marker. On S3 the writable mount checks the result of a single-key probe delete and refuses to open the pool if that delete reports a marker.

When only one key remains, CAS uses conditional DeleteObject. Only NoSuchKey settles the key as Gone. A bodyless HTTP 404 leaves the outcome unknown, so CAS retries with the original ETag within its retry budget. Under SingleAttempt, CAS owns credential refresh and retries. Other S3 failures identify the object key and preserve the S3 error name and type. Single-key and batch deletes share BlobStorageLogWriter::addEvent, which accepts the bucket name as a std::string_view.

If the response is lost, CAS can retry the keys from that attempt with their original ETag values. If S3 returns a DeleteObjects response that omits a requested key, repeats a key, or includes an unrequested key, CAS raises CORRUPTED_DATA and does not retry the delete.

On GCS, the mount skips the optional conditional batch probe for generation tokens. The S3-compatible XML DeleteObjects API rejects per-object ETag conditions. The GCS JSON batch API can group individual DELETE requests, each with its own ifGenerationMatch condition. CAS uses the XML API, verifies single-object conditional deletion at mount, and then reclaims each blob body with a separate x-goog-if-generation-match delete.

Local verification passed all 791 selected unit tests, including a scripted S3 test that returns DeleteMarker alongside SlowDown and checks that GC reports the marked key without retrying. A focused run of 64 unit tests covered the chunk limits and verified that CAS sends exactly one delete request for each malformed response. The RustFS 1.0.6 integration test used the real mount probe. Each of two isolated disks reclaimed six blobs in round 2, using six conditional requests at a chunk limit of one and three at a limit of two. Round 3 removed the six deletion intents from each disk. Direct listings confirmed cleanup of both prefixes. Live AWS S3 was not tested.

We recommend that QA repeat the RustFS scenario on a real Amazon S3 general purpose bucket where versioning has never been enabled. With a two-key chunk limit, verify that the writable mount logs Conditional batch delete probe passed, that GC reclaims six blobs in the same shard using three conditional DeleteObjects requests, and that a direct bucket listing confirms all six blobs are gone.

Upstream PR #70786 shows how ClickHouse previously detected ordinary DeleteObjects support by attempting a batch and interpreting the response.

Closes: #2480
Related: #2351
Related: #2917
Related: ClickHouse#70786

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Reduce S3 delete requests during CAS garbage collection by batching retired blob body deletes with a separate ETag condition for each object on supported storage.

Documentation entry for user-facing changes

CAS garbage collection: pending deletes

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Unit tests
  • Performance tests
  • Aarch64 tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • CAS (content-addressed storage; Antalya only)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • OAuth (5m)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • S3 Export (2h)
  • Swarms (30m)
  • Tiered Storage (2h)

@k-morozov k-morozov linked an issue Oct 9, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Workflow [PR], commit [5b23ca9]

@k-morozov

Copy link
Copy Markdown
Collaborator Author

rustfs/rustfs#8518

@filimonov

filimonov commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

I think we will need to add the feature test on disk start (add to other checks, but set the flag / show info instead of stop)

@k-morozov k-morozov mentioned this pull request Oct 28, 2026
4 of 74 tasks
@k-morozov

Copy link
Copy Markdown
Collaborator Author

#2876

@k-morozov
k-morozov changed the base branch from antalya-26.6 to antalya-26.8 November 17, 2026 16:58
k-morozov added a commit that referenced this pull request Nov 17, 2026
Resolve the CAS GC conflicts while preserving the antalya-26.8 marker-round semantics.

Related: #2534
k-morozov added a commit that referenced this pull request Nov 17, 2026
Bring the pull request up to the current release-branch tip after retargeting.

Related: #2534
k-morozov and others added 16 commits November 17, 2026 18:01
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Replace the parallel `io_results`, `io_errors` and `delete_submitted`
vectors in `Gc::redeleteBlobs` with one `RedeleteBlobState` per entry.
The observation result (`live_token`) is now separate from the delete
result (`del`), so `performRedeleteIo` becomes `observeRetiredBlob`.

Rename `applyRedeleteOutcome` to `recordRedeleteSuccess` and
`reportRedeleteFailure` to `recordRedeleteFailure`: the delete has
already run when they are called, and `Outcome` already names the
persisted `GcOutcomes` log. Rename the test hook and test names to match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Move the selection of token-matched entries and their split into
conditional delete chunks out of `Gc::redeleteBlobs` into
`Gc::prepareConditionalDeleteChunks`. The second wave now only submits
the prepared chunks, so `matched`, `delete_begin` and `delete_indices`
are gone.

The function and its value types are public so that the new
`CASGCConditionalDeleteChunks` tests can call it without a pool or a
backend request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Move the conditional delete chunk size calculation out of
`Gc::redeleteBlobs` into a method next to `Gc::bulkDeleteChunkKeys`.
No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Add `Gc::runRedeleteIoJobs` and use it for both the observation wave
and the conditional delete wave in `Gc::redeleteBlobs`. It runs jobs
inline when `concurrency <= 1` or there is at most one job, and on the
GC I/O pool otherwise. It returns per-job errors and the enqueue
refusal.

`jobs_scheduled` still counts only observation jobs submitted to the
pool. The delete wave now also runs inline at `concurrency <= 1`, and
both waves use one injected enqueue refusal message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Split the tail of `Gc::redeleteBlobs`:
- `Gc::recordRedeleteResults` records failures and successes and returns
  the error with the lowest entry index;
- `Gc::scheduleBlobMetaDeletes` schedules `.meta` deletion for `Removed`
  and `Gone` blobs;
- `Gc::redeleteBlobs` rethrows the error after both steps.

`Gc::recordRedeleteSuccess` no longer schedules `.meta` deletion, so a
later batch `.meta` delete changes only `Gc::scheduleBlobMetaDeletes`.
If recording throws, no `.meta` deletion is scheduled for the round; the
next round records the blobs as `Absent` and schedules it then.

Rename `RedeleteBlobState::del` to `removal` (it can come from the
observation wave, not only from a delete) and the wave results to
`observe_jobs` and `delete_jobs`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
k-morozov and others added 20 commits December 1, 2026 17:39
A backend limit can shrink after GC chooses its chunk size. Reject a chunk above the current limit before sending it and report both sizes. Cover the backend limit and the absolute cap of 1000 keys.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
A missing, unexpected or repeated key in a `DeleteObjects` response leaves the outcome of the batch ambiguous. Report `CORRUPTED_DATA` so CAS propagates the failure. Exercise each malformed reply with the standard retry policy and require exactly one delete request.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Move the object vector from the backend into `ConditionalDeleteBatch` so it owns the keys throughout response parsing. Borrow the bucket name as a string view until the request or log entry needs its own copy.

Name the backend attempt `removeManyIfTokensMatch` to distinguish it from the retrying `CasOperation::removeManyByConditional`.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Explain which keys GC retries after a lost response and why it stops on a response with missing, duplicate or unexpected keys. Describe how lowering the S3 disk limit can reject a chunk before it is sent.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Identify the probe prefix and the first unexpected per-key result or readback discrepancy. Report unsupported operations and skipped checks so operators can see why a mount uses single-key deletes.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
After workers finish, identify the failed chunk by round, shard, index, key count and first key. Count every pending row in the failed job and each enqueue refusal once so existing failure counters retain their units.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Describe how to find the probe decision and inspect a failed delete chunk. Align the operator reference with the delete marker exception, the failure counter units and the scope of `gc_bulk_delete_chunk_keys`.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
When `objects_chunk_size_to_delete` is 1, keep the mandatory single-key checks and skip the conditional batch probe before it writes any scratch keys. Log the configured limit. Raising it later allows batching once a subsequent mount verifies support.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Read the configured storage limit when opening the disk and pass the resulting flag to the capability probe for both writable mounts and pool migrations. This keeps single-key checks active without exposing the storage setting through CAS operations and backend decorators.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
After a partial delete, identify the first key still awaiting a result and the number of other pending keys in retry diagnostics. Name `objects_chunk_size_to_delete` when a chunk exceeds its limit, and explain that S3 can create delete markers with versioning enabled or suspended.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
A GC chunk can require multiple conditional requests after a partial failure, and the SDK can retry within a single call. Increment `DiskS3ConditionalDeleteObjects` each time the SDK signs a multi-key delete with per-key ETags. This also counts capability probes and leaves ordinary batch and single-key deletes out of the total.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
After a partial batch delete, a bodyless 404 on the remaining key leaves its outcome unknown. Verify that CAS retries only that key with its original `ETag` and reports `Mismatch` when S3 then rejects the precondition.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Run conditional deletes under the per-request retry window and honor a background stop before the first delete. Check the submitting thread group before a GC worker sends its chunk so a failed attachment leaves every key in that chunk intact.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Cover writable pool opens when the store rejects the conditional `DeleteObjects` probe. `NotImplemented` keeps the pool usable with a one-key limit. `InvalidRequest` and `InvalidArgument` must reach the caller with their original S3 error names.

Clarify how the single-key probe detects delete markers on S3 buckets with enabled or suspended versioning.

Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Explain why only `NoSuchKey` settles a conditional delete as `Gone`. Treating every HTTP 404 as absence could discard the deletion intent while the blob still occupies storage. Describe retries with the original `ETag` and the delete marker reported by single-key and batch deletes.

https: //docs.aws.amazon.com/AmazonS3/latest/developerguide/ErrorResponses.html#ErrorCodeList
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
A failed multi-key chunk inflated `jobs_failed` by its key count, while `jobs_scheduled` counted each enqueued chunk once. Count each failed pool job once so both metrics use the same unit. Inline failures and enqueue refusals remain visible through their dedicated counters.

Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
The S3 disk uses `support_batch_delete` for ordinary deletes. Document that CAS probes conditional deletion independently and skips that probe when `objects_chunk_size_to_delete` is one at mount.

Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Distinguish an explicit `NotImplemented` response or failed per-key checks from errors that prevent the pool from opening. Describe malformed requests and responses, persistent access failures and the retry window for transient errors.

Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
A shard with one delete chunk runs it inline, so an alert on `jobs_failed` misses that failure. Point operators to the phase counter for failed chunks and the round counter that also covers failed blob reads and enqueue refusals.

Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Local storage also skips the batch probe when its delete limit is one. Log that limit without pointing local disk operators to an S3 setting.

Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
Co-authored-by: Codex (GPT-6) <noreply@openai.com>
@k-morozov
k-morozov marked this pull request as ready for review December 2, 2026 11:54
@k-morozov
k-morozov requested a review from filimonov December 2, 2026 11:54
filimonov added a commit to filimonov/ClickHouse that referenced this pull request Dec 2, 2026
`utils/ca-soak/gc-bench`: how to run the `main` profile as a GC benchmark, the five-minute collector of
`system.events`, `system.cas_gc_log`, `system.cas_log` and `system.blob_storage_log`, a compose override for
RustFS 1.0.7 with `RUSTFS_DURABILITY_MODE=relaxed`, and three queries (rounds, store answers, requests per GC
phase). The README records how to reproduce the batch-delete overload seen with
Altinity#2534 on a slow store.

Signed-off-by: Mikhail Filimonov <mfilimonov@altinity.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@filimonov

Copy link
Copy Markdown
Member

Stand results for this PR on four stores, and the changes they suggest. Head 83e331483a1a, control c4d694a2e371, soak profile main, two replicas. Stand: utils/ca-soak/gc-bench/README.md on branch cas-gc-rebuild.

What the runs show

Store Conditional batch Result
S3 eu-central-1, new bucket used pending_deletes 66 s against 189 s on the control (38800 bodies). No aborted round. 41218 keys answered SlowDown
GCS disabled by the mount probe same as the control
RustFS 1.0.7, relaxed used no aborted round, but slower: 8.3 s of round time per 1000 condemned blobs against 6.9 s; 2.4 M keys timed out; inserts 19 % fewer
RustFS 1.0.6, strict, chunk 1000 used 14 Aborted rounds (gave up at the policy deadline after 16 attempt(s)), 4.6 M keys timed out, mount leases expired three times
same, chunk 128 used no aborted round; 289870 keys timed out, 56 answered on the first attempt, 76022 found gone on a repeat (interim, run in drain)
same, chunk 32 used no aborted round, 0 of 4895 chunks failed; 48576 keys timed out, 47430 found gone on a repeat

The cause is the same on every store: up to cas_gc_io_concurrency (16) chunks are in flight at once, and the store's delete rate is shared between them.

  • RustFS strict deletes about 115 keys per second in total. 16 chunks of 32 keys are 512 keys in flight: 512 / 115 = 4.5 s per chunk against cas_attempt_timeout_ms = 5 s. A chunk of 128 needs 18 s, a chunk of 1000 never ends.
  • RustFS runs a conditional batch as a serial loop over the keys (crates/ecstore/src/disk/local.rs, delete_versions_guarded_with_namespace_owner), 1.4 to 2 times slower than a plain batch. A client abort does not cancel it, so every repeat adds work to the store.
  • S3 accepted 7575 keys in one second and answered SlowDown to 15000 keys sent in one second (15 chunks of 1000 at once). The documented limit is 3500 writes per second per prefix. Three blob PUTs of writers got SlowDown in the same seconds.
  • A plain DeleteObjects from one thread takes 0.57 to 0.87 s on S3 for 430 to 870 keys, so one stream already deletes about 1000 keys per second.

Proposed changes

1. Cap the keys in flight, not the number of jobs.
cas_gc_io_concurrency counts jobs, and a job is now up to 1000 times heavier. Proposed cap for all conditional chunks together: 3500 (the S3 prefix limit) / 2 (half is left to writers) = 1750 keys, divided by the number of chunks in flight. With 16 chunks that is 109 keys per chunk.

The alternative is one chunk in flight. It is less code and enough on S3: one stream at about 1000 keys per second clears the 38800 bodies of the run in about 40 s (66 s with this PR, 189 s on the control), with no SlowDown. It is the wrong choice for RustFS-class stores: the store runs one batch as a serial loop, about 15 keys per second by the per-delete sync cost (derived, not measured for a batch), while 16 single deletes of the control reach 113 per second. Parallel small chunks keep that rate; one stream loses it.

The cap bounds the keys in flight, not the rate: chunks answered faster than a second can still pass 1750 keys per second. Item 3 covers that case.

2. Chunk size follows the response time.

  • The signal is the response time, not an error. A chunk answered in time t: if t is under a quarter of the attempt timeout, the next chunk is twice as large; over a half, twice as small; in between, unchanged. The timeout stays an emergency, not a way to measure: the size goes down before a request is cut.
  • The size lives in memory in Gc between rounds. It starts small (16) and is capped by cas_gc_bulk_delete_chunk_keys. The resume positions of cas_gc_round_intent_create_budget and cas_gc_round_redelete_budget are kept the same way; a new leader starts from 16 and reaches the working size in a few chunks.

With this, cas_gc_bulk_delete_chunk_keys = 1000 can stay the default as the ceiling. On RustFS strict with 16 chunks in flight the size settles near 8 to 16 keys (7 keys per second per chunk), which is the control's behaviour and rate; on S3 it grows to the cap of item 1.

3. After a timeout, ServiceUnavailable or SlowDown: smaller chunk and a longer pause.
Reset the size to the start value and double the pause before the next attempt, up to a cap. Today the whole chunk is sent again about 2 s later at the same size, up to 16 times. No extra HEAD is needed: a key the cut attempt already deleted answers as gone on the repeat, and that is already counted as absent.

4. A chunk that runs out of its window should not fail the round.
On strict each Aborted round repeated its fold: 184435 intent PUTs answered 412 and 190530 intent GETs in one run. Leaving the rows of the failed chunk pending for the next round costs nothing of that. This may belong to the round deadline work rather than to this PR; with items 1 to 3 the case should be rare.

5. Counters in the pending_deletes phase row.
delete_chunks and delete_chunk_jobs_failed are there. Missing: attempts cut by the timeout, keys sent again, the current chunk size. The numbers above had to be taken from system.blob_storage_log.error.

6. Elapsed time of deletes in system.blob_storage_log.
Three call sites in S3ObjectStorage.cpp pass a literal 0 as elapsed_microseconds:

Line (head 83e331483a1a) Path Added by
661 conditional batch delete, shared logger of ConditionalDeleteBatch this PR
839 single conditional delete, removeObjectIfTokenMatchesImpl #2159
933 plain batch delete #2300

On the S3 stand with this PR, 8 of 151575 Delete rows have a non-zero time. The upstream helpers measure it (deleteFileFromS3.cpp:46 per request, deleteFileFromS3.cpp:165 request time divided by the number of keys). Request: a Stopwatch around the request at these sites; for a batch, the request time divided by the number of keys, so the column means the same in every Delete row. The duration of a conditional chunk is the number items 1 and 2 are tuned by, and today it can only be estimated from rates. Lines 839 and 933 are already in antalya-26.8 and can go in a separate small PR.

Not proposed

  • A HEAD per key after a timeout to learn what was deleted: more requests on the path that has too many.
  • An attempt timeout that grows with the chunk size: cas_attempt_timeout_ms is part of the mount lease arithmetic, and 16 parallel chunks would still wait for minutes.

Check

RustFS 1.0.6 in strict mode reproduces the aborted rounds in 25 minutes; S3 shows SlowDown within the first long round. Both stands are in utils/ca-soak/gc-bench/README.md.

k-morozov and others added 2 commits December 3, 2026 13:37
Record the effective chunk limit, attempts that receive no response, and keys resent during the `pending_deletes` phase. Include failed attempts so an aborted round still shows how much work was retried.

Record S3 delete call duration in `system.blob_storage_log`. Divide batch duration among the requested keys so a sum across their rows accounts for the call once, up to integer rounding.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>
A lost response to a large conditional delete can cause GC to retry every key in the request. Divide `cas_gc_blob_delete_max_keys_in_flight` among the existing GC workers to bound the number of keys in concurrent requests from one GC.

Accept budgets from `cas_gc_io_concurrency` through 1500. Round the default down to a multiple of the worker count, giving 93 keys per request with 16 workers.

Co-authored-by: Codex (GPT-6) <noreply@openai.com>
Signed-off-by: Konstantin Morozov <just.morozov.k@gmail.com>

Copy link
Copy Markdown
Collaborator Author

Following up on filimonov’s original comment.

The PR addresses items 1, 5, and 6 and partially addresses item 3.

  • 1. Limit keys in flight — addressed. GC divides cas_gc_blob_delete_max_keys_in_flight across its I/O workers. With the default 16 workers, each conditional delete request contains at most 93 keys, for a total of up to 1,488 keys in concurrent requests per GC. This bounds concurrency. The request rate still depends on how quickly the store responds.
  • 3. Back off and shrink chunks under overload — partially addressed. When S3 returns per-key results, GC retries only the keys with retryable errors such as SlowDown. If the entire response is lost, GC retries all keys from that attempt. The existing retry policy uses exponential backoff with jitter. GC does not yet shrink the chunk or apply an additional delay specifically for overload.
  • 5. Expose retry and chunk metrics — addressed. The pending_deletes row in system.cas_gc_log now reports delete_blob_attempts_no_response, delete_blob_keys_resent, and delete_blob_keys_per_chunk. The first counts AWS SDK NETWORK_CONNECTION failures, including connection refusal. An S3 RequestTimeout response does not increment it. The last reports the effective chunk limit used for the last nonempty shard.
  • 6. Record delete latency — addressed. system.blob_storage_log now records elapsed time for single conditional deletes, conditional batch deletes, and ordinary batch deletes. For DeleteObjects, each per-key Delete row records the request duration divided by the number of keys, following the upstream convention.

The new key budget passed the focused unit tests and the RustFS integration test. Its effect on retries and INSERT throughput still needs a comparable load run on RustFS strict and AWS S3.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CAS: batches for pending_deletes

3 participants