Skip to content

CAS: SYSTEM CAS GC RUN on a follower silently does nothing (acquired_lease=0) #2211

Open

Description

@alsugiliazova

✅ I checked the Altinity Stable Builds lifecycle table, and the Altinity Stable Build version I'm using is still supported.

Type of problem

Usability / operator contract — the command the operator uses to “clean the pool now” can succeed with no reclamation and no error.

Describe the situation

SYSTEM CAS GC RUN is node-local. One GC leader holds gc/state. A manual run uses allow_steal = false (CasGcScheduler::runOneRoundNow). If this process is not the leader, acquireOrRenewLease fails, runRegularRound returns immediately with acquired_lease = false, and the interpreter still returns a success row of zeros.

The operator intent of GC RUN is “reclaim unreferenced blobs now.” A follower run does not do that. Nothing in the SQL error stream says so. You have to notice acquired_lease = 0 in the result block.

This is not the same as “always steal and run here.” Stealing from a live leader while that leader may be in a destructive phase is how two GC actors overlap (see tracking #2031 CAS-003). Forwarding the query to the leader is also not free: durable GcLease.owner is a random gc_id (UInt128), not a hostname, so a follower cannot print “leader is replica-2” from gc/state today.

This issue:

  • Silent no-op on a follower is the bug
  • Automatic steal of a live leader is the wrong fix
  • “Run as the leader” as a product goal is right; the cheap honest contract is fail loud (and, later, name the holder once gc/state carries a host identity)

How to reproduce the behavior

Environment

Steps

  1. Let background GC elect a leader (default: first writable mount that wins gc/state).
  2. On a replica that is not the GC leader:
SYSTEM CAS GC RUN cas_disk;
  1. Optionally compare:
SELECT hostName(), disk, server_root_id, is_leader
FROM clusterAllReplicas('{cluster}', system.cas_mounts)
WHERE disk = 'cas_disk';

is_leader is only populated on the local server_root_id row (StorageSystemContentAddressedMounts.cpp — NULL on other members’ mounts). Finding the leader requires querying every replica.


Expected behavior

A command whose purpose is pool reclamation should not look like success when it did not reclaim.

Reasonable contract (in order of preference):

  1. Fail closed if this node did not acquire the lease: exception (or a non-zero exit / NOT_A_LEADER code) stating that this RUN had no effect, that another GC holds gc/state, and how to proceed (RUN ON CLUSTER, or system.cas_mounts / clusterAllReplicas where is_leader = 1).
  2. Do not steal from a live leader on manual RUN. Overlapping destructive rounds is worse than a loud no-op.
  3. If we want “always actually clean, from any node” without steal: either ON CLUSTER must fail if zero nodes acquired the lease, or gc/state must publish hostname / server_root_id so the error can name the holder, or the query must be forwarded to that holder. None of that exists today.

SYSTEM CAS GC RUN ON CLUSTER … already fans out and the leader’s row gets acquired_lease = 1. That is a workaround, not a contract: the operator still has to read N rows and notice the zeros.


Actual behavior

On a follower (release)

The query returns a row, acquired_lease = 0, all reclaim counters 0. Finish in system.cas_gc_log is NotALeader. No exception.

Anchors:

  • CasGcScheduler::runOneRoundNow — allow_steal = false
  • Gc::runRegularRound — if !acquired_lease, return empty RoundReport
  • InterpreterSystemQuery::appendContentAddressedGcRoundRow — still emits a success row
  • GcLease (CasGcStateFormat.h) — {owner: UInt128, seq} only; no host

ON CLUSTER

Same query on every replica. One row may show work; the others are silent no-ops. Easy to treat the statement as “the cluster GCd” after looking at any single follower row.


Root cause analysis

Leadership is a pool-wide compare-and-swap on gc/state. Manual RUN correctly refuses to steal (so it will not interrupt a live leader). It then fails open in the SQL contract: “we didn’t run” is encoded as a flag in a successful result, not as a failure. system.cas_mounts.is_leader cannot name a remote leader from one node. Together, the operator cannot achieve “clean the pool” from a random replica without already knowing the GC-leadership model.


Additional context

  • Docs already say a manual run executes regardless of GC STOP (background pause only). They do not say a follower run is a no-op.
  • Related: CAS — consolidated static analysis audit findings (tracking) #2031 CAS-003 (steal vs live destructive GC). This issue is the operator-facing half: don’t steal, but don’t pretend the pool was cleaned.

Activity

  1. self-assigned this
    on Aug 19, 2026
  2. filimonov commented on Aug 20, 2026

    @filimonov
    Member

    Confirmed. Two parts:

    No-steal on manual RUN is deliberate (commit 2026-07-13). Declaring a leader "frozen" needs two observations separated by real wall time — only the background loop's paced ticks guarantee that. Two manual RUNs can land microseconds apart, wrongly mark a live leader as frozen, and put two destructive GC actors on the pool. This stays.

    The silent follower row was never a designed contract. RUN already returns a result set (one row per disk: acquired_lease, round, the reclaim counters) — it was added just to expose the internal round report, and nobody decided that a follower should look like success. On a follower the row is honest but easy to misread: acquired_lease = 0 plus zeros. It will be fixed, but not by throwing: with the default distributed_ddl_output_mode = throw, a throwing follower breaks ON CLUSTER the other way — the leader runs the round, the other nodes throw, and the whole statement reports failure. A node cannot tell it is part of an ON CLUSTER fan-out, so selective throwing is not possible.

    Planned instead:

    1. RUN result gets a finish column (Success / NotALeader / Deferred — already in cas_gc_log, just not shown here).
    2. gc/state gets the leader's hostname (advisory field, same as the mount lease already has). A follower row then says NotALeader, leader_host = 'replica-2' directly — no discovery query needed.
    3. system.cas_mounts.is_leader gets filled for all mounts, not only the local one.
    4. No steal on manual RUN — unchanged.
  3. added 4 commits that reference this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions