Skip to content

id(libsql): limit half-open circuit breaker to one recovery probe #8798

Closed

Description

@dezren39

Evidence

In pkgs/id/src/foreign_libsql.rs, CircuitBreaker::allow returns true for every call in BreakerState::HalfOpen (around lines 923–936). The first caller after BREAKER_HALF_OPEN_AFTER changes Open to HalfOpen and is admitted; while that remote call is still in flight, any number of other callers are also admitted. The state remains half-open until a call records success or transient failure. This is the recovery path in the adapter shipped by #8115 (merged; #7577 is closed).

The breaker is intended to probe a recovered endpoint before resuming regular traffic. Admitting an unbounded concurrent burst defeats that purpose and can overload an endpoint that is only beginning to recover.

Acceptance criteria

  • Half-open admits at most one in-flight recovery probe per breaker; concurrent callers are rejected or wait according to the chosen API policy.
  • A successful probe closes the breaker and resets the failure count.
  • A failed probe reopens the breaker and starts a fresh recovery delay.
  • Tests cover repeated calls while one probe is outstanding, plus success and failure transitions; include a concurrent test if the implementation can be exercised concurrently.
  • Closed-state admission and the existing open-state delay behavior remain unchanged.

Follow-up to merged implementation PR #8115 and issue #7577; this is a newly identified edge case, not a duplicate of the adapter implementation request.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions