Skip to content

Antalya 26.8: Cache terminal CAS mount slot ETags in computeHeartbeatFloor - #2996

Open
sks wants to merge 2 commits into
Altinity:antalya-26.8from
stackgenhq:fix/antalya-26.8/cas-gc-terminal-mount-and-fold-seal-cache
Open

sks wants to merge 2 commits into
Altinity:antalya-26.8from
stackgenhq:fix/antalya-26.8/cas-gc-terminal-mount-and-fold-seal-cache

Conversation

@sks

@sks sks commented Dec 2, 2026 •

Copy link
Copy Markdown

Split out from #2920 per review feedback as a single-purpose atomic PR for the terminal mount slot ETag cache (MountTerminalCache).

Changes

  • Terminal Mount Slot ETag Cache (CasServerRoot.h/.cpp, CasGc.h/.cpp):
    • Cache terminal (gc_fenced and clean-release) mount slot ETags across GC rounds in Gc::mount_terminal_cache (MountTerminalCache).
    • When computeHeartbeatFloor() lists gc/server-roots/ and observes an unchanged LIST ETag for a cached terminal slot, it classifies the slot (already_fenced or terminated) directly without issuing a per-slot GET/readModifyWrite.
    • If a successor reclaims the slot (changing its ETag) or the slot is removed, the cache entry is invalidated/pruned automatically.
  • Tests (gtest_cas_gc_round_defer.cpp):
    • Added CASGCRoundDefer.CachesTerminalMountSlotEtagsAcrossRounds verifying that gc_fenced and clean-release terminal mount slots are read once and skipped on subsequent rounds when their LIST ETag is unchanged.

Request & Cost Numbers

With default settings (cas_gc_interval_sec = 60 -> 1,440 rounds/day; AWS S3 GET pricing at $0.40 / 1M):

  • Saves M_term GETs per GC round (1,440 * M_term GETs/day, where M_term is the number of historical gc_fenced or clean-release mount slots under gc/server-roots/).
  • For a cluster that has accumulated 20–100 retired/fenced mount slots (e.g. across rolling restarts or ephemeral pod replacements), this eliminates 28,800 to 144,000 GETs/day (864k to 4.32M GETs/month, $0.35–$1.73/month) and keeps heartbeat_floor latency O(M_live) rather than growing with historical terminal slot count.

Changelog category (leave one):

  • Performance Improvement

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

Cache terminal (gc_fenced and clean-release) CAS mount slot ETags across GC rounds in computeHeartbeatFloor to skip redundant per-slot GETs when the listed ETag is unchanged.

Documentation entry for user-facing changes

  • Documentation is written (internal GC request deduplication; no user-facing configuration changes)

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)

Split out from Altinity#2920 per review feedback:

Cache terminal (`gc_fenced` and clean-release) mount slot ETags across
GC rounds in `MountTerminalCache` (`Gc::mount_terminal_cache`) so
`computeHeartbeatFloor()` skips per-slot `GET`/`readModifyWrite` calls
when `LIST` returns an unchanged ETag.

Signed-off-by: sabith <sks@stackgen.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sks
sks force-pushed the fix/antalya-26.8/cas-gc-terminal-mount-and-fold-seal-cache branch from 8b1c34d to 8e0b01b Compare December 3, 2026 01:25
@sks sks changed the title Antalya 26.8: Cache terminal CAS mount slot ETags and per-round fold seals in GC Antalya 26.8: Cache terminal CAS mount slot ETags in computeHeartbeatFloor Dec 3, 2026
@filimonov filimonov added the CAS label Dec 3, 2026
@filimonov

Copy link
Copy Markdown
Member
  1. The test seems to be broken? In gtest_cas_gc_round_defer.cpp, the ephemeral-released slot is not a clean release: it needs min_active_build_sequence = std::numeric_limits<uint64_t>::max(), not expires_at_ms = 0. As written, the round 2 and round 3 assertions on it should fail, and the clean-release branch has no coverage.

  2. Add an invalidation test. Overwrite a cached fenced slot with a live body: the next pass must GET it and count it live. Without this, a cache that never invalidates would pass the tests.

@sks sks closed this Dec 3, 2026
@sks sks reopened this Dec 3, 2026
…nvalidation on reclaim

CatchesTerminalMountSlotEtagsAcrossRounds seeded the "clean-release" slot with
`expires_at_ms = 0`, which is not a terminal slot: `MountLease::isCleanRelease()`
is the `min_active_build_sequence == UINT64_MAX` farewell sentinel. As written the
slot stayed live, the round-2/round-3 zero-GET assertions failed on it, and the
clean-release classification branch of `MountTerminalCache` had no coverage.

Add.InvalidatesTerminalMountCacheWhenSlotChanges: a cached `gc_fenced` slot is
overwritten with a live body under a successor reclaim (new ETag); the next round
must GET the new body again, count the slot `live`, and never classify it
`already_fenced` from the stale cache entry. A second round still GETs it because
a non-terminal body erases its cache entry — without this, a cache that never
invalidates would pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Signed-off-by: sabith <sks@stackgen.com>
@sks
sks force-pushed the fix/antalya-26.8/cas-gc-terminal-mount-and-fold-seal-cache branch from e5543ab to d53460a Compare December 3, 2026 22:29
@sks

sks commented Dec 3, 2026 •

Copy link
Copy Markdown
Author

Both review points are addressed in commit d53460a:

  1. gtest_cas_gc_round_defer.cpp CASGCRoundDefer.CachesTerminalMountSlotEtagsAcrossRounds — the released slot is now seeded with min_active_build_sequence = std::numeric_limits<uint64_t>::max() (the MountLease::isCleanRelease() farewell sentinel), not expires_at_ms = 0. This is exactly the failure the Unit tests (asan_ubsan) CI job caught (gtest_cas_gc_round_defer.cpp:752, 758 — ``ephemeral-released getCount` 1 vs 0); with the sentinel the clean-release branch of `MountTerminalCache` is actually exercised and the round-2/round-3 zero-GET assertions hold.

  2. New test CASGCRoundDefer.InvalidatesTerminalMountCacheWhenSlotChanges — a cached gc_fenced slot is overwritten with a live body (successor reclaim, new ETag); the next round must GET the new body again, count the slot live (and not already_fenced from the stale cache entry), and a second round still GETs it because reading a non-terminal body erases the cache entry.

Validated locally: CASGCRoundDefer.* 18/18 pass; ; CASGCRound*, CASHeartbeat*`, CASMountAudit*`` 107/107 pass.

Note: the force-push that landed d53460a seems to have reset the workflow approval — the PR workflow run 47217881198 is sitting at action_required. Could you please approve the run so CI picks it up?

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