Skip to content

scheduler: standby replicas log leader-held at INFO on every acquire attempt, burying the log #778

Closed

Description

@jhrozek

Summary

On a multi-replica deployment, every non-leader replica logs at INFO on every
lease-acquire attempt, forever. With mecak8s at 2 replicas this is roughly one line
every 2 seconds for the life of the pod, which buries everything else in the log.

internal/adapter/scheduler/scheduler.go:607:

default:
    // ErrLeaseHeld (a peer leads) or a transient infra fault: standby.
    if errors.Is(err, port.ErrLeaseHeld) {
        s.diag.Log(ctx, port.LevelInfo, "another replica is the scheduler leader; standing by",
            "owner", s.cfg.LeaseOwner)
    }
    ...
    if !s.sleepOrDone(ctx, jitteredBackoff()) {

The loop is correct — jittered backoff exists precisely to avoid a thundering herd on
the lease backend. The problem is only that the log fires per attempt rather than
per state change.

Observed

Real output from the fixture's standby replica:

time=2026-08-27T08:16:44.713Z level=INFO msg="another replica is the scheduler leader; standing by" component=scheduler owner=mecak8s-...-qhdwg-1-fcf3deb58ca1cd05
time=2026-08-27T08:16:46.863Z level=INFO msg="another replica is the scheduler leader; standing by" component=scheduler owner=mecak8s-...-qhdwg-1-fcf3deb58ca1cd05
time=2026-08-27T08:16:48.831Z level=INFO msg="another replica is the scheduler leader; standing by" component=scheduler owner=mecak8s-...-qhdwg-1-fcf3deb58ca1cd05
time=2026-08-27T08:16:51.457Z level=INFO msg="another replica is the scheduler leader; standing by" component=scheduler owner=mecak8s-...-qhdwg-1-fcf3deb58ca1cd05

Impact

This is not cosmetic. Diagnosing an unrelated session problem on that deployment
required filtering the line out before anything else was visible; two successive
kubectl logs | grep passes over a 20-minute window returned nothing at all
because the surrounding lines had scrolled past the tail. It also inflates log
volume and cost for any deployment shipping INFO to a log backend, in proportion
to replica count and uptime.

Suggested fix

Log the transition, not the attempt: emit once when the replica enters standby and
once when it leaves (acquires, or the error class changes), and drop it to DEBUG for
the per-attempt case. The ErrLeaseHeld branch is a steady state, not an event.

The sibling LevelWarn branch a few lines below (a transient acquire failure) has
the same shape and is arguably worse, since a persistent infra fault would emit a
WARN per backoff. Sticky-once, in the style of Engine.save's
Run.saveWarned, would fit both.

Notes

Found while diagnosing the mecak8s vMCP Kind fixture, but it is not
fixture-specific: it affects any multi-replica deployment with a leasing scheduler
backend. Single-replica deployments never hit it, since they acquire the lease.

Activity

  1. added 2 commits that reference this issue on Aug 27, 2026
    b82a189
    e305161
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions