Skip to content

CAS: refuse to republish a namespace life retired during a cold admission - #2570

Closed
filimonov wants to merge 10 commits into
antalya-26.6from
fix/antalya-26.6/cas-378-retired-life-republish
Closed

filimonov wants to merge 10 commits into
antalya-26.6from
fix/antalya-26.6/cas-378-retired-life-republish

Conversation

@filimonov

@filimonov filimonov commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

A cold admission of a namespace runtime could publish a life that was retired while it waited, and a re-created table then wrote acknowledged files into that dead life. The cold path reads the catalog row (Live, life L), then takes ref_queue_mutex to install the runtime; no lock is held in between. If DROP TABLE and the GC drain retire L in that window, invalidateRemovedCatalogLife erases the name's slot, and the delayed insertion installs a runtime for L into the empty slot. A table re-created with the same UUID then gets L from the warm namespaceLife, putNamespaceFile acknowledges its files, and the dead-life janitor deletes them.

Changes

  • RefNameSlot keeps a retirement count. invalidateRemovedCatalogLife bumps it under ref_queue_mutex and clears the slot's runtime instead of erasing the slot, whatever runtime is resident, including a successor's. Evicting an idle runtime whose removal admission is closed or whose terminal removal is applied also bumps the count, so a life drained by another server's GC leader (which never calls invalidateRemovedCatalogLife here) still leaves a record. A slot with a non-zero count is never erased.
  • The GC drain records each retirement before it erases the catalog row (before_erase callback of deleteCompletedRemovingAtSnapshot), not after the drain returns.
  • The cold paths capture the count before their first catalog read: acquireReadableRefTableRuntime, namespaceLife, namespaceStillLogicallyPresent, dropNamespaceImpl, acquireMutableRefTableRuntime. acquireRefTableRuntime refuses with a retryable error if the count moved; the retry re-reads the catalog.
  • The warm namespaceLife refuses a runtime whose recovered state is terminal.
  • Read paths (acquireReadableRefTableRuntime, namespaceStillLogicallyPresent) refuse a stale observation with the transient-unavailability wording (NETWORK_ERROR kept) instead of "CAS write could not be committed".

Risks / notes

  • A retirement record stays in memory until the pool remounts. The GC leader keeps one small entry per name retired anywhere in the pool; every server also keeps one per name it dropped whose runtime was evicted. Clearing earlier would reopen the window.
  • A concurrent cold admission of another life of the same name can take one extra retry.
  • No on-store format change.

Testing

  • New gtests (fail on the base): a cold reader and a cold writer whose catalog read is followed by DROP and two GC rounds (a test backend runs them during the second catalog GET); a retirement recorded while a successor is resident survives its eviction; namespaceLife refuses a recovered terminal life.
  • A cold reader parked after its second catalog read and released right after the drain's catalog erase returns is refused (ColdReaderIsRefusedWhenReleasedRightAfterTheDrainErasesItsRow).
  • A cold admission is refused when another server's GC leader drained the life and the owner's runtime was evicted (ColdAdmissionIsRefusedWhenARemoteLeaderRetiredTheLifeAndTheRuntimeWasEvicted).
  • The reconciler announces each life once, before its row is erased, and a failing announcement sends no erase (AnnouncesEachLifeBeforeItsRowIsErased, AFailingAnnouncementSendsNoErase), and once across a conflict retry (RetriesFromTheMandatoryConflictResolutionCut).
  • A read refused by the retirement record carries no write wording (ColdReaderDoesNotRepublishALifeRetiredAfterItsCatalogRead).
  • CAS* unit tests on dca5e45ce32: release 2639, ASan 2643, all passed.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

CAS: a table dropped and re-created with the same UUID could have acknowledged table files deleted by GC, when a concurrent read admitted the dropped table's namespace while the drop completed.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

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)

filimonov and others added 3 commits October 13, 2026 02:24
A cold reader could see the catalog row `Live`, then lose the CPU before
`acquireRefTableRuntime` took `ref_queue_mutex`. Removal plus the GC drain
retired the life and erased the slot, so the reader inserted a fresh runtime
for the dead life. A warm `namespaceLife` then returned it and
`putNamespaceFile` acknowledged bytes the dead-life janitor later deletes.

- `RefNameSlot` keeps a per-name `retirements` count;
  `invalidateRemovedCatalogLife` bumps it instead of erasing the slot, also
  when no runtime is resident. Eviction keeps slots with a non-zero count.
- Every cold path captures the count before its first catalog GET;
  `acquireRefTableRuntime` throws retry-later if it moved.
- `namespaceLife` refuses a recovered runtime whose terminal removal is
  applied.

Draft: not built or tested yet.

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
`invalidateRemovedCatalogLife` returned without bumping the name's
retirement count when a successor life was resident. A delayed cold
admission of the predecessor could then insert it once the successor was
evicted. The count is now bumped for every retirement, while invalidation
and detachment stay limited to the exact predecessor runtime.

New tests:
- a delayed predecessor retirement with a successor resident advances the
  count, leaves the successor attached, and the count survives eviction;
- `namespaceLife` refuses a recovered terminal runtime whose removal-admission
  flag is clear, on the cold call and on the warm one;
- the cold `namespaceLife` window between its catalog read and its insertion.

Draft: not built or tested yet.

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Draft: not built or tested yet.

Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Workflow [PR], commit [dca5e45]

@filimonov

Copy link
Copy Markdown
Member Author

Stateless tests (amd_binary, cas s3 storage, parallel) and Stateless tests (amd_debug, parallel): Server died with Logical error: GroupingAggregatedTransform pushed bucket A twice. The stack is in aggregation (MergingAggregatedMemoryEfficientTransform), no CAS frames; the same failure hits other PRs on this base. Not related to this PR. Tracked upstream: ClickHouse#115986

@alsugiliazova

Copy link
Copy Markdown
Member

PR #2570 Audit Review

Verdict

No High defect. The guard is correct for the window it was written for, and the window it was written for is the real one. A cold admission that reads a Live catalog row can no longer install a runtime for a life that was retired while it waited, as long as the retirement was recorded in this process before the insertion.

Two Medium gaps, both from one root: the retirement record is written after the catalog row is already gone, and only in the process that happens to hold the GC lease. One Low on the memory and lock cost of a record that is never released before remount.

What the change does

RefNameSlot gains a retirements counter. invalidateRemovedCatalogLife bumps it under ref_queue_mutex and clears the slot's current instead of erasing the slot (CasRefLedger.cpp 710–744). enforceRefTableCacheBudget erases a slot only while its count is zero (1829–1830); quiesceRefTablesForRemount's ref_name_slots.clear() (1886) is the only other way a record leaves memory.

Five cold paths capture the count before their first catalog read and hand it to acquireRefTableRuntime, which refuses with a retryable error if the count moved (590, 622):

Path Capture
acquireReadableRefTableRuntime 655, before the first of its two catalog reads
namespaceLife (cold arm) 4974, before the catalog read
acquireMutableRefTableRuntime 698, before namespaceLife
namespaceStillLogicallyPresent 5054, before the first read
dropNamespaceImpl 5138, before mount_requests.admit()

A second gate, refuseTerminalLife (4996–5005), refuses to hand namespaceLife's caller a runtime whose recovered stream carries an applied RemoveNamespace. It fires on both the warm arm (4967) and the cold arm (4992), and deliberately permits a never-born stream, which is also Removed but carries no remove_txn_id.

Several test accessors in CasRefLedger.h (477–505, 547–554) gained null checks on current, which they now need because a slot can outlive its runtime.

Model

Actors Each ClickHouse server mounting the pool under its own cas_server_root_id, the one GC leader among them, and the shared object store
Channels The pool-wide ref catalog object, each namespace's ref-log stream and _ckpt, and the mount lease. No Keeper
Authoritative state The catalog row decides whether a life exists. ref_name_slots is a per-process cache of life handles; putNamespaceFile takes a NamespaceLifeId and performs no catalog check, so the handle is the write authority
Failure model assumed by the code A cold admission may stall for an unbounded time between its catalog read and its runtime insertion. Retirement is a durable, one-way catalog event performed by the GC leader
Safe failure criterion No caller is ever handed a life whose catalog row has been drained; a write that is acknowledged is not later swept by the dead-life janitor

The central argument, and why it holds

The race the PR describes is real and the shape of the fix matches it. The slot, not the runtime, is what must remember a retirement, because invalidateRemovedCatalogLife used to erase the whole map entry and the delayed insertion then found an empty name and filled it. Keeping the entry and clearing only current is what gives the late insertion something to compare against.

Comparing by != rather than > is right. The count is monotone within one mount: a slot with a non-zero count is never erased, so it cannot ABA back to a value a stalled caller captured. Across a remount the count resets to zero with ref_name_slots.clear(), and that case is covered by the independent fence-generation check in the same critical section (generation_moved, 587), since a remount always moves the generation.

Recording whatever runtime is resident, a successor included, is also right. The successor's own eviction cannot drop the record, which the new RetirementWithASuccessorResidentIsRecordedAndSurvivesEviction test pins with a one-byte cache budget.

The second gate earns its place. Where the counter misses, a runtime installed for a retired life still recovers from that life's durable stream, finds the terminal RemoveNamespace, and refuseTerminalLife refuses it. The two gates fail together only after the dead-life janitor has swept the stream, at which point recovery cannot tell a retired life from a never-born one.

Findings

Timing / ordering

Medium: the retirement is recorded one or more object-store round trips after the catalog row is erased.

  • Impact. A cold admission that inserts inside that interval is admitted with the pre-retirement count and installs a runtime for a life whose row is already gone. That is the exact outcome the PR exists to prevent.
  • Anchor. Gc::runRegularRound (CasGc.cpp 689–691) and the rebuild path (4433–4435) collect drain_result.retired_lives and call store->invalidateRemovedCatalogLife only after drainCompletedRemoving has returned. CatalogLifecycleReconciler::reconcile (CatalogLifecycleReconciler.cpp 72–119) issues the durable delete inside its loop, then re-reads the catalog, then selects again, and ends with refresh_authority() — which is Gc::refreshAuthority (CasGc.cpp 4909–4928), an object-store GET.
  • Trigger. One eligible Removing row. The drain deletes it, performs its resolution read and the authority probe, and returns; the cold admission's insertion lands anywhere in there. With several eligible rows the interval is longer by one delete and one read each.
  • Why defect. The invariant the counter carries is "no life of this name has been retired since my observation". Between the erase and the bump that statement is already false while the count still reads its old value, so acquireRefTableRuntime takes the admitting branch.
  • Fix direction. Record the retirement before the delete rather than after — thread a pre-delete callback through deleteCompletedRemovingAtSnapshot. A bump not followed by an erase is harmless: it costs one retry.
  • Regression test direction. Fire the cold admission's insertion from a hook placed between the catalog delete and the drain's return, and assert the runtime is refused. The current tests fire their hook at the catalog read, which is the wide end of the window and leaves this end untested.

Medium: a retirement performed by a remote GC leader is never recorded on the server that owns the namespace.

  • Impact. On a pool whose GC lease sits on another server, the new counter never moves for a drained life, so the guard contributes nothing there. The surviving defense is refuseTerminalLife, which stops working once the janitor has swept the retired life's stream.
  • Anchor. invalidateRemovedCatalogLife is reached only from the GC leader's drain (CasGc.cpp 691, 4435), from dropNamespaceImpl's stalled-Creating cancellation (CasRefLedger.cpp 5163), and from reconcileCatalogCut (748–768), which a server reaches only through the removal_admission_closed arm of namespaceLife (4951–4962). CatalogLifecycleReconciler::selectEligible (CatalogLifecycleReconciler.cpp 29–45) drains every Removing row in the pool-wide catalog regardless of which server_root_id owns it.
  • Trigger. Server B owns the namespace, server A holds the GC lease. B drops the table; A drains the row. B's runtime for the dead life then goes idle and enforceRefTableCacheBudget erases its slot outright, because B's count for that name is still zero (CasRefLedger.cpp 1829). A cold admission on B that read the row while it was Live now captures zero before and after, inserts, and recovers a stream the janitor has already swept — which presents as a never-born life and passes refuseTerminalLife. A table re-created with the same UUID then writes into it.
  • Why defect. The counter is a happens-before edge between two events in one process, used to order an event that is pool-global and performed elsewhere. The eviction rule that protects the record — "never erase a slot whose count is non-zero" — cannot protect a record that was never written.
  • Fix direction. Pin the name on any local evidence of removal, not only on the retirement callback: refuse to erase a slot whose last resident runtime carried removal_admission_closed or an applied terminal removal. That keeps a non-zero record on the owning server without needing the leader's notification.
  • Regression test direction. Two pools over one backend, GC driven from the second, drop and drain from there, evict the first pool's slot, then release a cold admission that observed the Live row. The existing tests all drive GC from the same Pool as the racing caller, so none of them covers this.

Backpressure and resource limits

Low: on the GC leader, every namespace retired anywhere in the pool leaves a permanent map entry.

  • Impact. ref_name_slots grows with the number of tables dropped pool-wide since the mount, and every full walk of that map happens under the global ref_queue_mutex.
  • Anchor. invalidateRemovedCatalogLife uses ref_name_slots[life.ns.string()] (CasRefLedger.cpp 717), creating a slot for a name this process has never cached, then returns at 721 leaving it empty. enforceRefTableCacheBudget will not erase it (1829). Only quiesceRefTablesForRemount (1886) clears it. The map is walked end to end under the queue mutex by enforceRefTableCacheBudget twice per call (1778, 1791), which runs on every recovery completion via 1695, by reconcileCatalogCut (755) on every GC round, by wedgedRefLaneCount (1985) behind the system.cas_mounts column, and by drainRefLanesForShutdown (2012).
  • Trigger. Being the GC leader on a pool with table churn. The leader records lives belonging to every other server_root_id, not just its own.
  • Why defect. The PR's note calls this "one small entry per retired name", which is accurate for the owning server and understates the leader, where the set is the pool's drop history rather than this process's cache history. The memory is small per entry; the cost that bites first is the growing walk under a mutex that every ref append also needs.
  • Fix direction. Release retirement records once no cold admission can still be holding a stale capture — for instance, keep a process-wide count of in-flight cold admissions and drop the records when it reaches zero.
  • Regression test direction. Retire N namespaces owned by a peer server_root_id and assert the leader's slot count does not grow by N.

Observability and diagnosability

Low: the new refusal is worded as a write failure on paths that are not writes.

  • Impact. A SELECT or a presence probe that loses this race surfaces CAS write could not be committed (CAS namespace '…': a life of this name was retired while life … was being admitted; retry from a fresh catalog observation); retrying later. The wrapper text names a write that was never attempted, and nothing in the sentence says the table was dropped.
  • Anchor. throwCasWriteRetryLater (Backend/CasRequests.cpp 92–96) fixes that prefix for every caller; the new throw sites are reached from acquireReadableRefTableRuntime (691) and namespaceStillLogicallyPresent (5099).
  • Why defect. Pre-existing in kind — the adjacent row-changed refusal has the same shape — but this PR adds two more read-path users of a write-flavored sentence.
  • Fix direction. Use the sibling disk-state refusal for the read paths, or name the drop in the text.

Two things that look like defects and are not, recorded so the next reader does not re-derive them. enforceRefTableCacheBudget moves out of it->second.current and then skips the erase when the count is non-zero (1828–1830); the moved-from shared_ptr is null, so the slot is left empty rather than dangling. And acquireMutableRefTableRuntime now captures admitted_generation before namespaceLife instead of after (697), which can turn a cold mutation into a retry when the fence moves during the catalog read; that fails closed through the pre-existing generation_moved path and is the safer of the two orderings.

Coverage

Class Result
Network / transport Reviewed. No change to attempt bounds, backoff, or error classification. Both new throws reuse the existing retryable NETWORK_ERROR shape.
Partition / availability Reviewed. The guard only ever refuses, never admits, so it cannot split-brain a namespace. The stale-read window after a remote retirement is the second finding.
Timing / ordering Reviewed. The counter is monotone within a mount and backstopped by the fence generation across one. Both Medium findings are this class.
Partial / gray failure Reviewed. An ambiguous catalog delete that leaves the row absent still produces a retirement record, so the count may move without an erase; that costs one retry and nothing else.
Idempotency and duplicates Reviewed. A repeated invalidateRemovedCatalogLife for the same life bumps the count twice at most and only forces an extra retry. dropNamespaceImpl's terminal-state early return (5191) is unchanged.
Backpressure and resource limits Reviewed. The unreleased record is the third finding.
Recovery and rollback Reviewed. refuseTerminalLife deliberately permits a never-born stream, which is also what a swept retired life looks like; that is the limit the second finding turns on. Remount still clears every slot and every record.
Configuration and version skew N/A. No on-store format change; the counter is in-memory and invisible to peers.
Security / trust across nodes N/A. No authentication or authorization change.
Observability Reviewed. The wording finding is this class.

Assumptions: static reading of head 19b5df85. GC leadership, the drain's eligibility rule, and the per-server_root_id namespace rooting were taken from the same commit and from docs/en/antalya/cas/architecture/mounts-and-leases.md. No server was run and no test was executed.

Operational readiness

Scope. DROP TABLE followed by a CREATE/ATTACH that reuses the UUID, on a CAS disk, at head 19b5df85. Persona: operator / DBA.

Primary flows

  1. INSERT into a table on a CAS disk while another table on the same pool is being dropped. (most common)
  2. DROP TABLE then re-create or ATTACH with the same UUID.
  3. SELECT from a table whose namespace is being dropped concurrently.

Issues

1. A retryable error on an insert that names a namespace the operator did not touch

  • Symptom. CAS write could not be committed (CAS namespace '…': a life of this name was retired while life … was being admitted; retry from a fresh catalog observation); retrying later.
  • Trigger. Flow 1. The statement's first touch of a cold namespace loses a race against that namespace's drop and drain.
  • Signal quality. Clear about the cause, and it names the namespace rather than the table.
  • Severity. Low. The retry succeeds — the next attempt re-reads the catalog and either mints a fresh life or finds the row gone.
  • Recovery. Self-service: retry the statement.

2. The same error text appears on a read

  • Symptom. A SELECT fails with a sentence that begins CAS write could not be committed.
  • Trigger. Flow 3. See the third finding.
  • Signal quality. Confusing. The error claims a write.
  • Severity. Low.
  • Recovery. Self-service: retry.

3. On a non-leader server the dropped-then-recreated case is still exposed

  • Symptom. Silent. Namespace files written after the re-create are deleted by GC, and the table reads back short.
  • Trigger. Flow 2, on a server that does not hold the GC lease, with a cold admission stalled across the drop, two GC rounds, and an eviction of that namespace's runtime. See the second finding.
  • Signal quality. Silent — this is the pre-PR failure mode surviving in a narrower window.
  • Severity. Medium, with a narrow trigger.
  • Recovery. Engineer required; the files are gone.

Readiness verdict

  • Flow 1 (insert during an unrelated drop): ready. The worst case is a retryable error.
  • Flow 2 (drop then re-create with the same UUID): ready with caveats. On the GC leader the window is closed except for the interval in the first finding. On any other server it is narrowed, not closed (issue 3).
  • Overall: a clear improvement over the base, which lost acknowledged files on a plain single-process race. Ship it; the remaining exposure is narrower than what it replaces.

Operator guidance

Treat a life of this name was retired while life … was being admitted as retryable, on reads as well as writes. When re-creating a table with the same UUID on a pool with several servers, confirm the drop has fully drained — system.cas_mounts shows which server is is_leader — before the first insert, rather than issuing DROP and CREATE back to back.

Recommended fixes

  1. Record the retirement before the catalog delete, not after the drain returns (first finding).
  2. Keep a slot pinned on local evidence of removal so the record does not depend on holding the GC lease (second finding).
  3. Release retirement records once no cold admission can hold a stale capture (third finding).
  4. Use the disk-state refusal, not the write refusal, on the read paths (fourth finding).

@alsugiliazova

Copy link
Copy Markdown
Member

PR #2570 CI Verification

Verdict

No regression in what ran. Approval is blocked on what did not: every CAS regression suite was skipped.

Six checks are red. Not one of them is a named test failure that the diff can reach. Two stateless jobs died on the same GroupingAggregatedTransform assertion, which is live on the branch and on thirty other pull requests this quarter. One unit test is an Iceberg UBSan report that fails one run in five across the fork. One integration shard hit the three-hour xdist session timeout after passing every test it ran. Two Grype scans report Alpine distro CVEs in openssl.

Category Count Where
regression 0 —
pre-existing-flaky 3 the aggregation abort on Stateless tests (amd_debug, parallel) and on Stateless tests (amd_binary, cas s3 storage, parallel); IcebergMetadataGenerator.ModifyColumnAfterItselfWithoutTypeIsNoop on Unit tests (asan_ubsan)
infrastructure 3 Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/8), GrypeScanServer (-alpine), GrypeScanKeeper
cascade 2 Server died on each of the two stateless jobs
unknown 0 —

The blocking item is not in that table because it is not a failure. The PR body ticks ci_regression_cas, and all eleven RegressionTestsRelease / CAS* jobs plus TieredStorageCAS came back skipped, while every other ticked suite ran. See The CAS regression suites never ran.

How the list was reduced

gh-data.checks holds five FAIL rows on this PR, all from the one run.

  1. Cascades, two rows. Server died sits beside the GroupingAggregatedTransform abort in both stateless jobs, at the same check_start_time. The abort has an abortOnFailedAssertion stack, so this is a real debug assertion, not a harness kill and not an OOM.
  2. Rates, the three remaining rows. Both resolve against the branch and other pull requests without further work. Counts are in the findings.
  3. Environment, from the log text. The integration shard was interrupted by its own session timeout with zero failing tests; Grype reports distro advisories against a base image this diff does not change.
  4. Nothing reached individual investigation, and nothing is unknown.

Only the head commit ever got a CI run. The PR has three commits — 06ac915b, e8177d91, 19b5df85 — and the first two have no workflow run at all, so there is one data point per failure and no rerun to compare against.

What passed, and why it matters here

This is a CAS-internal change, so the CAS-flavoured jobs are the relevant signal, and they are green:

Job Result
Stateless tests (amd_asan_ubsan, cas s3 storage, parallel, 1/2) success, 5,561 OK
Stateless tests (amd_asan_ubsan, cas s3 storage, parallel, 2/2) success, 5,593 OK
Stateless tests (amd_binary, cas storage, parallel) success, 11,270 OK
Stress test (amd_asan_ubsan, cas s3 storage) success
Stress test (amd_debug, cas s3 storage) success
Stateless tests (amd_binary, cas s3 storage, parallel) red, but 8,395 OK and Failed: 0 — see the abort below

The PR's own new tests are covered. Unit tests (asan_ubsan) ran 2,593 CAS* gtests to [ OK ], including the four added by this PR, under both AddressSanitizer and UndefinedBehaviorSanitizer. The job is red for an Iceberg test, not a CAS one.

Every regression suite that ran is clean in clickhouse_regression_results on this head: iceberg_1, iceberg_2, oauth, parquet, parquet_aws_s3, parquet_minio, s3_export_part, s3_export_partition, swarms. Zero Fail and zero Error rows across all of them; swarms is 1,535 OK, with none of the name must be specified suite errors seen on neighbouring pull requests.

Findings

The CAS regression suites never ran

The PR body ticks the CAS regression box:

- [x] <!---ci_regression_cas--> CAS (content-addressed storage; Antalya only)

Every CAS job in the run came back skipped: CAS, CASSuite, CASAggregateFunctions, CASAlter, CASLightweightDelete, CASS3Cache, CASS3CacheSuite, CASS3CacheAggregateFunctions, CASS3CacheAlter, CASS3CacheLightweightDelete, and TieredStorageCAS. The other ticked suites — Iceberg, OAuth, Parquet, S3Export, Swarms — all ran and passed in the same run, so this is not a workflow-wide skip. clickhouse_regression_results has no CAS rows for this head, which agrees.

That matters more for this change than it would for most. The diff alters when a namespace runtime may be published and adds a gate that refuses a writer outright, so its realistic failure mode is a retryable error raised where none was raised before — a DROP-then-recreate sequence that now returns CAS write could not be committed (…); retrying later. The stateless CAS jobs exercise CAS storage but do not drive namespace drop and recreate the way the CAS regression suite does, and the four new gtests prove the gate fires, not that nothing else trips over it.

Not a failure, and not evidence of one. It is a hole in the evidence, and it is the hole most likely to contain a problem with this specific diff. Re-run with the CAS suites before approving.

Stateless tests (amd_debug, parallel) and Stateless tests (amd_binary, cas s3 storage, parallel) — pre-existing-flaky

One debug assertion, hit independently in both jobs:

Logical error: 'GroupingAggregatedTransform pushed bucket 4 twice'   (amd_debug)
Logical error: 'GroupingAggregatedTransform pushed bucket 5 twice'   (cas s3 storage)

from src/Processors/Transforms/MergingAggregatedMemoryEfficientTransform.cpp:63. Server died in each job is the harness record of that abort.

Neither job reported a failing test. amd_debug finished Failed: 0, Passed: 10758, Skipped: 106; cas s3 storage finished Failed: 0, Passed: 8389, Skipped: 102. The jobs are red because of the fatal.

Counted by commit over 60 days:

Job Side Commits With this abort
Stateless tests (amd_debug, parallel) other PRs 623 11 (1.8%)
antalya-26.6 branch 80 0
PR 2570 1 1
Stateless tests (amd_binary, cas s3 storage, parallel) other PRs 320 16 (5.0%)
antalya-26.6 branch 20 0
PR 2570 1 1

The branch zeros on those two job names are not a clean baseline, because the abort is not confined to them. On branch runs it has fired eleven times across nine different stateless jobs in the same window, including the CAS-storage variants: arm_binary, parallel (3), amd_binary, cas storage, arm_binary, cas s3 storage, amd_msan, cas s3 storage, amd_tsan, cas s3 storage, amd_tsan, parallel, amd_tsan, s3 storage, amd_asan_ubsan, distributed plan, amd_msan, WasmEdge. It is a branch-wide problem that lands on whichever job happens to schedule the query.

Across all jobs it has hit thirty pull requests in 60 days and is still live: the two most recent hits are PRs 2644 and 2420, both on 2026-10-23, nine days after this PR's run. The assertion is in aggregation transform code; this diff touches CasRefLedger, CasPool.h, and one gtest file, with no path to it.

Unit tests (asan_ubsan) — pre-existing-flaky

IcebergMetadataGenerator.ModifyColumnAfterItselfWithoutTypeIsNoop fails on a UBSan report:

/ClickHouse/src/DataTypes/IDataType.h:380:67: runtime error: member call on null pointer of type 'DB::IDataType'
  #0 DB::WhichDataType::WhichDataType(...)            src/DataTypes/IDataType.h:380:67
  #1 DB::isNothing(...)                               src/DataTypes/IDataType.cpp:520:1
  #2 DB::Iceberg::stripNothing(...)                   src/Storages/.../Iceberg/MultipleFileWriter.cpp:34:9
  #3 DB::Iceberg::checkUnknownTypeAllowed(...)        src/Storages/.../Iceberg/Utils.cpp:554:32
Who Runs Fails Rate
Other PRs, this job 179 38 21%
antalya-26.6 branch, this job 13 1 7.7%
PR 2570 1 1 one run

Fifteen other pull requests hit it in the window, most recently 2574 and 2567 on 2026-10-19. The stack is entirely in Iceberg metadata generation and IDataType; the diff touches neither. One failure against a 21% baseline is what that baseline predicts.

Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/8) — infrastructure

The shard passed everything it ran and was then killed by its own deadline:

!!!!!! xdist.dsession.Interrupted: session-timeout: 10800.0 sec exceeded !!!!!!!
==== 617 passed, 43 skipped, 1 xfailed, 11 warnings in 10829.94s (3:00:29) =====
Error [Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/8)]
  | Test execution was interrupted (exit status: 2)

The database agrees: 619 OK, 43 SKIPPED, and zero FAIL rows for this job on this PR, with check_status = error recorded at job level only. Shards 2/8 through 8/8 all succeeded.

This shard is the slow one and runs close to its budget routinely. Counted by commit over 60 days: antalya-26.6 branch 5 of 37 commits red (13.5%), other pull requests 40 of 408 (9.8%), PR 2570 1 of 1. An asan+ubsan integration shard that overruns three hours about one time in eight is the baseline, not a new failure mode. Rerun.

GrypeScanServer (-alpine) and GrypeScanKeeper — infrastructure

Both scans fail on Alpine distro advisories, severity High, against openssl 3.3.7-r1 in the libcrypto3 and libssl3 apk packages — namespace alpine:distro:alpine:3.21, fixed upstream in 3.3.7-r2. CVE-2026-84782 is the DTLS retransmission out-of-bounds read; CVE-2026-84784, CVE-2026-85091 and CVE-2026-72897 are alongside it on the keeper image.

The finding ids are distro package matches, not anything compiled from this diff, and the diff changes no Dockerfile, package list, or image base. A rerun scans the same base layer and fails identically. These clear when the base image picks up the patched apk, not on this PR.

Recommendation

Do not approve yet — re-run CI with the CAS regression suites enabled. Nothing in the current run implicates the diff, and the CAS stateless and stress jobs plus 2,593 CAS gtests under asan and ubsan are real positive signal. But the suite that would exercise a namespace drop and recreate against a live server never ran, and that is precisely the path this change alters.

Once the CAS suites are green, approve on CI grounds. Of the six current reds, a rerun may clear the two stateless aborts (1.8% and 5.0% per commit) and the integration shard (about 10%). It will not clear Grype, and the Iceberg unit test fails on roughly one in five runs across the fork, so either may stay red. None of those should block.

@alsugiliazova

Copy link
Copy Markdown
Member

@alsugiliazova alsugiliazova added the verified Approved for release label Oct 23, 2026
@filimonov
filimonov changed the base branch from antalya-26.6-20261008 to antalya-26.6 October 24, 2026 11:30
@filimonov filimonov assigned filimonov and k-morozov and unassigned filimonov Nov 3, 2026
@k-morozov
k-morozov self-requested a review November 3, 2026 11:13
k-morozov
k-morozov previously approved these changes Nov 3, 2026
filimonov and others added 7 commits November 4, 2026 01:58
The GC drain recorded a retired life only after the erase and the
resolution reads that follow it. A cold admission that inserted its
runtime inside that interval saw an unchanged retirement count and
published a runtime for a life whose row was already gone.

`deleteCompletedRemovingAtSnapshot` now takes a `before_erase` callback
that runs once, after admission is confirmed and before the first erase.
The GC drain passes `invalidateRemovedCatalogLife`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
A life drained by another server's GC leader is never reported to the
owning server, so the owner's idle runtime was evicted with a zero
retirement count and its slot erased. A cold admission that had read the
row `Live` before then installed a runtime for the dead life.

`enforceRefTableCacheBudget` now bumps the count, and so keeps the slot,
when the evicted runtime had closed its removal admission or applied a
terminal removal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
A `SELECT` or presence probe that lost the retirement race failed with
"CAS write could not be committed", naming a write that was never
attempted. Read paths now use the disk-state refusal; the error code is
unchanged. Write paths keep their wording.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
The parked thread registers itself before its first request instead of
being assigned after the thread starts, and a guard releases and joins it
when an assertion fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
The drain announces every retired life before its erase, so re-recording
after the drain only bumped the count twice. Comments that placed the
invalidation after the deletion now say it can precede the erase.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mikhail Filimonov <[email protected]>
@filimonov

Copy link
Copy Markdown
Member Author

Thanks for the audit. Status per finding:

  • Medium 1, the retirement was recorded after the catalog-row delete. Fixed in 7673004: deleteCompletedRemovingAtSnapshot takes a before_erase callback that runs once before the first erase, and the GC drain passes invalidateRemovedCatalogLife. A throwing callback sends no erase. The post-drain invalidation loops are gone (f95440d): every life the drain retires is announced before its erase, including an erase that committed but was reported fenced out. Tests: ColdReaderIsRefusedWhenReleasedRightAfterTheDrainErasesItsRow, AFailingAnnouncementSendsNoErase, RetriesFromTheMandatoryConflictResolutionCut (announced once across a retry).
  • Medium 2, a retirement by a remote GC leader was not recorded on the owner. Fixed in 30f75bb: evicting a runtime that closed its removal admission or applied a terminal removal keeps the slot's retirement record. Test: ColdAdmissionIsRefusedWhenARemoteLeaderRetiredTheLifeAndTheRuntimeWasEvicted.
  • Low 3, the leader keeps an empty slot per retired name. Not changed here; with Medium 2 every server keeps one small record per name it dropped and evicted. Tracked as a follow-up.
  • Low 4, "CAS write could not be committed" on read paths. Fixed in d7135ea: read paths refuse with a transient-unavailability message and keep NETWORK_ERROR.

CI: the CAS regression jobs did not run on the last head although ci_regression_cas is ticked; the next push runs a fresh CI on the current antalya-26.6 base.

@filimonov

filimonov commented Nov 13, 2026 •

Copy link
Copy Markdown
Member Author

For 26.6 - abandoned (real bug, but narrow).

For 26.8 - becomes a part of #2831

@filimonov filimonov closed this Nov 13, 2026
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.

4 participants