Skip to content

Antalya 26.8: Short-circuit idle CAS GC rounds, cache terminal mount ETags, and suppress idle heartbeats - #2920

Open
sks wants to merge 1 commit into
Altinity:antalya-26.8from
stackgenhq:fix/antalya-26.8/cas-gc-idle-shortcircuit
Open

sks wants to merge 1 commit into
Altinity:antalya-26.8from
stackgenhq:fix/antalya-26.8/cas-gc-idle-shortcircuit

Conversation

@sks

@sks sks commented Nov 18, 2026

Copy link
Copy Markdown

Problem

Even on an idle CAS pool where zero new parts are written and shouldDeferRound defers the fold, CasGcScheduler and CasGc still execute substantial background S3 request volume:

  • CasGcScheduler::heartbeatLoop() writes gc/hb (GET + PUT) every hb_interval = interval / 4 even when no round is running (!round_in_flight), and onLeaseAcquired() pulses gc/hb synchronously on every steady-state renewal.
  • computeHeartbeatFloor() calls readModifyWrite (GET) on every /mount slot under gc/server-roots/, including immutable terminal (gc_fenced and clean-release) slots whose LIST ETag has not changed.
  • CasGc::runRegularRound() reads the same fold_seal key multiple times per round, unconditionally forces a full fold() every gc_fold_max_defer_rounds (8) rounds even when changed_shards == 0, and re-reads cas/ref_catalog and namespace_cleanup on every idle tick.

Changes

  • CasGcScheduler (CasGcScheduler.h/.cpp):
    • Skip gc/hb pulses in heartbeatLoop() when !round_in_flight && !last_round_failed_transiently. Because acquireOrRenewLease() bumps gc/state.lease.seq every interval, followers still observe steady-state leader liveness, while active long folds and transient-failure recovery retain full gc/hb protection.
    • Skip the synchronous pulseHeartbeat() in onLeaseAcquired() on steady-state renewals when already leader.
  • computeHeartbeatFloor (CasServerRoot.h/.cpp):
    • Cache terminal (gc_fenced / clean-release) mount ETags across rounds in Gc::mount_terminal_cache and skip GET/readModifyWrite when LIST returns the matching Etag.
  • CasGc & CasNamespaceJanitor (CasGc.h/.cpp, CasNamespaceJanitor.h/.cpp):
    • Add a per-round CasFoldSeal cache (readFoldSeal) so a single round reads a given (generation, attempt) fold seal at most once (and zero times for generation 0).
    • Compute a SipHash (key, etag) fingerprint in enumerateRefPrefix() and track NamespaceJanitorResult::has_pending_work. Once a DEFER round settles with changed_shards == 0, zero non-Live catalog entries, and a clean janitor sweep, subsequent idle rounds short-circuit when !graduationDue, cas/ref_catalog ETag matches, and the cas/ns/stream/ fingerprint matches — skipping pre_fold_ref_drain, walk-plan rebuild, namespace_cleanup, and periodic empty folds.
  • Tests & Docs:
    • Added CASGCRoundDefer.SteadyStateIdleShortCircuitsWithoutForcedEmptyFoldsAndWakesOnPublish in src/Disks/tests/gtest_cas_gc_round_defer.cpp.
    • Updated fold_seal_reads expectation in src/Disks/tests/gtest_cas_gc_log.cpp.
    • Documented the idle short-circuit behavior in docs/en/antalya/cas/architecture/garbage-collection.md.

Changelog category (leave one):

  • Performance Improvement

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

Short-circuit idle CAS GC rounds when the catalog ETag and ref-stream listing fingerprint are unchanged, cache terminal mount ETags and per-round fold seals, and suppress gc/hb pulses between healthy idle rounds.

Documentation entry for user-facing changes

  • Documentation is written: updated docs/en/antalya/cas/architecture/garbage-collection.md.

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)

…and suppress idle heartbeats

Reduces idle S3 traffic on settled CAS pools without weakening lease-steal or deletion safety:

1. CasGcScheduler: suppress periodic gc/hb writes in heartbeatLoop() when no round is in flight and the last round did not fail transiently; skip synchronous gc/hb write in onLeaseAcquired() on steady-state leader renewals (gc/state lease seq bump already proves liveness).
2. computeHeartbeatFloor (CasServerRoot): cache terminal (gc_fenced / clean-release) mount ETags across rounds and skip per-slot GET/readModifyWrite when LIST returns the same ETag.
3. CasGc: add per-round CasFoldSeal cache (avoiding duplicate fold_seal GETs and gen-0 404s) and steady-state IdleBaseline short-circuit (comparing catalog ETag and cas/ns/stream/ (key, etag) SipHash fingerprint) so settled idle pools skip drain, walk-plan, janitor re-scans, and periodic forced empty folds.
4. Update gtest_cas_gc_round_defer.cpp, gtest_cas_gc_log.cpp, and docs/en/antalya/cas/architecture/garbage-collection.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sabith <sks@stackgen.com>

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