Skip to content

kvserver: replace circuit breaker cancel goroutine with per-Replica registry #74707

@tbg

Description

@tbg

Touches #33007.

As of #71806, replica circuit breakers default to off since they use a simple
but inefficient mechanism to fail-fast requests that are inflight while the
breaker trips.

We want to improve on that by adding a registry of the cancel functions on Replica
and by letting the probe cancel everyone. This saves one goroutine per request and
should have a small perf impact once suitably optimized.

Prerequisite for #74705.

Describe the solution you'd like

type Replica struct {
  // ...
  breakerCancelsMu {
    syncutil.Mutex
    sl []func()
  }
}

func (r *Replica) sendWithRangeID(...) {
  ctx, cancel := ...
  r.breakerCancelsMu.Lock()
  r.breakerCancelsMu.sl = append(..., cancel)
  r.breakerCancelsMu.Unlock()
}

Metadata

Metadata

Assignees

Labels

C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions