Skip to content

Reads of nonexistent objects permanently disabled the mount (two mechanisms, one classification defect) #175

Closed

Description

@scttfrdmn

Summary

Two independent defects composed into a total, permanent read outage on an entirely healthy S3. Both are fixed in 9c54e83; this issue records the defect, the verification, and the reasoning, because the failure mode is instructive and the fix touches a hot path.

Reading ten objects that do not exist took the mount offline for the life of the process — including reads of objects that did exist.

The two defects

1. A refusal was counted as a failure. pkg/health.RecordError incremented ConsecutiveErrors for any error at all, including NoSuchKey. With UnavailableThreshold: 10, ten reads of absent keys drove the s3-reads component to StateUnavailable, after which CanRead refused every read.

A 404 for an object nobody wrote is not evidence the service is unwell. It proves S3 is up, reachable, authenticating, and answering correctly — it is the filesystem equivalent of a successful call.

2. StateUnavailable had no exit. The only thing that cleared it was RecordSuccess, and the only RecordSuccess("s3-reads") call in the backend lives in getObjectRange — which GetObject never reaches, because it checks the availability gate first and returns. From the state that needed a success, no success could be produced. Two supposed escape hatches were both dead:

  • TrackerConfig.RecoveryThreshold: 5 is configured, documented, and read by nothing.
  • Tracker.StartHealthChecks has no callers anywhere in the repo, so no out-of-band success could arrive either.

Verification

Proven by execution, not inference. A probe test against the real backend over real HTTP:

read 1..10 of a missing key   → consecutive_errors 1 → 10
at 10                          → canRead=false
read of an object that EXISTS  → refused, SERVICE_UNAVAILABLE
20 further reads               → never recovered

After the fix, the same sequence: consecutive_errors=0 throughout, and the object that exists reads back its bytes.

Why this is not an exotic input

Ten stats of absent paths is an ordinary minute in the life of a filesystem: shell tab-completion, a build system probing for headers, any open(O_CREAT) of a new file, ls in a directory a tool is populating. ObjectFS's own Lookup does one HeadObject per path component. This is a load-bearing path, not an edge case.

Why unit tests missed it

pkg/health's own tests cannot see defect 2. From inside the package, RecordSuccess clears the state correctly — the bug is that the caller returns before reaching it. That is a seam defect: a value correctly produced at one layer and dropped at the boundary. It took a test through the composed real backend to surface.

It was found by internal/difftest's shrinker, which reduced a 44-operation program to a single one-byte write and then reported a health divergence rather than the durability defect the program had been built to contain. The reduction looked like a harness artifact and was not.

Fix

One authority, not two. The health tracker and the circuit breaker are two independent mechanisms guarding the same S3 call, and both got the same classification question wrong. Fixing only one moves the outage rather than removing it — with the health gate fixed, the seam test showed the s3-get breaker opening on the same sequence and producing the same refusal.

  • pkg/errors.IsServiceFailure(code) — the single predicate for "is this evidence the service is unwell, or an ordinary answer to an ordinary request." It enumerates the non-failures and returns the negation, so a code added later defaults to counting. That direction is deliberate: the failure mode of forgetting to update the list is a component that degrades too eagerly and recovers on its probe timer, not one that never notices a real outage.
  • internal/circuit.defaultIsSuccessful asks it, instead of testing err == nil.
  • pkg/health.RecordError asks it, and records a non-failure as a success — because that is what it is.
  • TrackerConfig.ProbeAfter (default 30s): a component that has been refusing operations admits one through to find out whether the service came back. This is the circuit breaker's half-open state, which internal/circuit already implemented correctly on a timer and this layer simply lacked. ProbeAfter: 0 opts out.

Three design points in the probe that are easy to get wrong:

  • A clean probe recovers the component outright rather than decrementing ConsecutiveErrors. The gate admits one operation per interval, so a decrementing recovery from ten errors would need ten successes and ten intervals. An explicit probing flag makes the probe's outcome decisive in both directions.
  • Admission is gated on a timestamp (nextProbe), not on the probing flag. Gating on the flag would rebuild the exact defect being fixed: a probe whose outcome never arrives — a panicking caller, a path that forgets to record — would latch the component forever. A timestamp costs one interval instead.
  • A failed probe does not escalate the state. The component was already refusing operations; a confirmed failure is no reason to go further. The clock is simply rearmed.

admissionState takes an RLock fast path, since every read and every write passes through it and a healthy component is never a probe candidate. The write lock is taken only when a probe is actually due, with a re-check under it so a burst of concurrent callers yields exactly one probe — an outage must not be met with full load.

Tests

  • pkg/health/admission_test.go — 9 tests. The classifier is pinned at 30 errors, 3× UnavailableThreshold, so a pass cannot be a pass by staying under a limit. Also asserts GetState still reports unavailable during a probe: a probe is permission to try, not a recovery.
  • internal/storage/s3/health_gate_test.go — the composed path through the real backend over real HTTP, which is the only place either fix can be shown to be insufficient alone.
  • internal/circuit/breaker_test.go — 100 NoSuchKey executions leave the breaker closed, and a clean call afterwards is actually invoked.

Follow-ups

  • TrackerConfig.RecoveryThreshold is still read by nothing. Either honour it or delete it — a configuration knob that silently does nothing is its own defect.
  • Tracker.StartHealthChecks still has no callers. It is the intended source of out-of-band recovery signal and is currently dead code.

Activity

  1. added
    type: bug
    priority: critical
    area: core
    area: health
    on Jul 31, 2026
  2. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Fixed in v0.10.1 (34ad91d, d0a93e0). A HEAD that 404s is now absence, not a service failure — the two are distinguished at four separate seams. Previously a read of a nonexistent object counted against the health tracker and the circuit breaker, so ordinary events in the life of a filesystem (shell tab-completion, a build system probing for headers, any open(O_CREAT) of a new file, and ObjectFS's own Lookup, which does one per path component) drove the mount to permanently unavailable with no recovery path. Both mechanisms and the missing recovery are fixed; found by difftest.Shrink, which reduced a 44-operation program to a single one-byte write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corearea: healthpriority: criticaltype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions