Skip to content

Clarify CAS orphan manifest sweep state and test pause and resume - #2954

Open
k-morozov wants to merge 4 commits into
antalya-26.8from
feature/cas-orphan-sweep-cleanup
Open

k-morozov wants to merge 4 commits into
antalya-26.8from
feature/cas-orphan-sweep-cleanup

Conversation

@k-morozov

Copy link
Copy Markdown
Collaborator

This is a follow-up to #2800. The sweep schedule decides whether an ordinary GC fold scans a page of manifest keys. A zero list budget already pauses the sweep, so the fold can use the schedule decision directly. A GC test now pauses a two-page scan, verifies that the paused fold issues no manifest LIST, and restores the budget to finish from the saved cursor.

The format test covers a generation 4 gc/state record with both sweep cursors and no completion timestamp. The GC documentation describes that upgrade path. The fold tests also drop clock overrides that kept the sweep from running, and their names describe what triggers a fold.

Built clickhouse and unit_tests_dbms locally. All 813 focused C++ tests passed, and the 05814_cas_orphan_manifest_sweep_schedule stateless test passed through Praktika.

Related: #2800

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

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

Added regression coverage for resuming a paused CAS orphan manifest sweep and for preserving sweep cursors when upgrading GC state.

Documentation entry for user-facing changes

Updated the CAS garbage collection and format documentation and clarified how setting cas_manifest_sweep_list_budget_keys to zero affects an in-progress sweep.

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 and others added 4 commits November 24, 2026 12:48
Exercise a generation 4 `gc/state` record with both sweep cursors and no completion timestamp. Document how the timestamp is interpreted and drop the description of an intermediate format that never shipped.

Co-authored-by: Codex (gpt-6.2-astra) <[email protected]>
Signed-off-by: Konstantin Morozov <[email protected]>
Fold deferral is independent of the orphan manifest sweep interval. Let the fixtures exercise the ordinary GC path, including the sweep page in the ref catalog test.

Co-authored-by: Codex (gpt-6.2-astra) <[email protected]>
Signed-off-by: Konstantin Morozov <[email protected]>
The tests exercise the ordinary fold trigger after a sweep failure or suppression. Their names previously implied a separate sweep retry deferral policy.

Co-authored-by: Codex (gpt-6.2-astra) <[email protected]>
Signed-off-by: Konstantin Morozov <[email protected]>
The schedule already disables the sweep when its list budget is zero. Remove the duplicate check in `fold` and exercise a two-page scan across a pause. Restoring the budget must resume at the saved cursor and record completion after the last page.

Co-authored-by: Codex (gpt-6.2-astra) <[email protected]>
Signed-off-by: Konstantin Morozov <[email protected]>
@github-actions

Copy link
Copy Markdown

Workflow [PR], commit [13b8324]

@alsugiliazova

Copy link
Copy Markdown
Member

PR #2954 Audit Review

AI audit note: This review was generated by AI (Claude Opus 5.5).

Field Value
PR Altinity/ClickHouse#2954 — Clarify CAS orphan manifest sweep state and test pause and resume
Follow-up to Altinity/ClickHouse#2800
Author k-morozov
Base antalya-26.8
Head 13b8324ed9ef4fbb830503495ca50bbe7018074b
State at review Open
Size 4 commits, 11 files, +62 / −51. One production line in CasGc.cpp. One setting description and one header comment. The rest is tests and docs
Scope reviewed Full diff at head. Also read: orphanManifestSweepDecisionOf and updateOrphanManifestSweepSchedule (CasOrphanManifestSweepSchedule.cpp), the decision and commit sites in Gc::runRegularRound (CasGc.cpp around lines 916 and 1360), Gc::fold (around line 3810), planManifestCursorPage (CasOrphanManifestSweep.cpp:701), decodeGcState (CasGcStateFormat.cpp), and Pool::config (CasPool.h)
Method Static review at head, walking the distributed-systems fault classes. Nothing was built or run

Verdict

No confirmed distributed-systems defects in reviewed scope.

The only behavior change removes the manifest_sweep_list_budget_keys > 0 guard from Gc::fold. That is safe:

  • orphanManifestSweepDecisionOf returns Disabled first when the budget is 0, so run_orphan_manifest_sweep is false and fold skips the sweep.
  • fold has one caller (CasGc.cpp:1030), and it passes that decision.
  • The decision and the fold read the same store->poolConfig(). Pool::config is written only when the pool opens, so the budget cannot change between the two reads within a round.
  • planManifestCursorPage still returns early on a zero budget, with no LIST, orphan_manifest_sweep_page_listed == false, and the cursor unchanged. A zero budget is therefore still checked in two places.
  • At commit, the cursor and schedule are updated only when orphan_manifest_sweep_page_listed is true, so a paused round preserves both. The new test ReenablingListBudgetResumesFromSavedCursor covers this path: pause, then no manifest LIST and the same schedule, then resume from the saved cursor to EOF.

Model assumptions

  • Actors: GC leader (lease holder) on one server; other servers that may take over the lease; object storage that holds gc/state and the manifest keys.
  • Channels: Object storage LIST, read, and compare-and-swap (replace with an etag) on gc/state.
  • Failure model assumed by code: Crash-recover GC processes. Lease takeover between rounds. Lost gc/state CAS races. Node-local pool settings, which can differ between servers.

Lower-severity notes

  • Low (test coverage). The PR deletes ReadsPriorThreeFieldState. That was the only gc/state test that decoded an object with unknown keys (orphan_manifest_sweep_active, orphan_manifest_sweep_started_at_ms). decodeGcState still ignores unknown keys through r.skipUnknown, so behavior is unchanged. The format battery has a helper for this, withExtraKeyInLine (cas_format_test_battery.h:68), but nothing calls it. Nothing now catches a decoder change that starts rejecting unknown keys. That decoder behavior is what lets an older GC read a newer node's gc/state with an extra field at the same header generation. Fix direction: keep a one-line test that decodes a gc/state with an extra key, or call withExtraKeyInLine from the battery.
  • Low (docs, compatibility). The PR removes the README and GC-doc text on the three-field schedule, including "rollback to the intermediate reader is unsupported." The three-field writer (a213170d7af, Nov 5) and its replacement (b3c79a88426, Nov 17) both landed on antalya-26.8, and no release tag contains only the first. So the text describes only pre-release builds, and dropping it is reasonable. A pool written by a dev build from that window still decodes correctly, as described in the note above.
  • Note (mixed settings). manifest_sweep_list_budget_keys is node-local. If one server sets it to 0 and another doesn't, the sweep pauses or advances depending on which node holds the lease. The cursor survives either way, so the only cost is slower sweeping. This was already the case before the PR, and the new setting description ("pauses the sweep and preserves its cursor") states it correctly.

What was checked and found clean

  • Pause and resume across a lease holder or restart. The cursor lives in gc/state and is committed by CAS. A paused round writes it back unchanged, and reopenPool in the new test models a restart with the new setting.
  • Schedule invariant. updateOrphanManifestSweepSchedule throws LOGICAL_ERROR if it gets a Disabled or SkipUntilIntervalElapsed decision. It can no longer be reached with a zero budget, because page_listed is false.
  • Suppressed rounds. The !suppress_destructive guard is unchanged at both the fold and the commit sites.
  • Upgrade from generation 4 without the completion timestamp. The new test decodes it as completed_at_ms == 0, which means unknown and starts a sweep on the next fold. It re-encodes at G_BLOB_INTENTS and keeps both cursors.
  • Removed clock overrides in fold tests. With completed_at_ms == 0, the decision is StartSweep whatever the real clock reads, so the tests stay deterministic. Deferred rounds don't fold, so they don't run the sweep either.
  • Version skew. No wire-format change. The encoder and decoder are untouched.

Coverage

Fault class Status Note
Network / transport Reviewed Paused rounds issue no manifest LIST. No new I/O
Partition / availability N/A No quorum or leader logic changed
Timing / ordering Reviewed The decision clock sample and the completion stamp are unchanged
Partial / gray failure Reviewed A lost gc/state CAS leaves the cursor as committed
Idempotency & duplicates Reviewed Resume uses the committed cursor. A page is never applied twice
Backpressure & resource limits Reviewed A zero budget stops the sweep's LIST and body reads
Recovery & rollback Reviewed Restart and pool reopen keep the cursor. Rollback to a pre-release three-field reader is undocumented, which is acceptable as noted above
Configuration & version skew Reviewed Node-local budget, no wire change, unknown keys still skipped
Security / trust N/A No authentication or authorization path touched
Observability Reviewed run_orphan_manifest_sweep is reported as 0 when the sweep is paused. The setting description is now accurate

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.

3 participants