apache/druid · warning

I'm being asked to become leader. But I am already the…

Error message

I'm being asked to become leader. But I am already the leader. Ignored event.

What it means

CuratorDruidLeaderSelector's isLeader() listener callback fired while the local `leader` flag was already true, meaning Curator reported a leadership grant for an existing leader. The event is ignored with a warning to keep the term counter and leadership state consistent.

Solutions

  1. Generally harmless: the node is correctly still the leader and the duplicate event is dropped.
  2. If leadership appears stuck, verify the listener.becomeLeader() side effects ran for the current term (check term counter in logs).
  3. Investigate ZK session instability that triggers spurious re-grants.
  4. Avoid registering multiple listeners on the same CuratorDruidLeaderSelector instance.
Defensive patterns

Strategy: try-catch

Try / catch

// make becomeLeader idempotent so duplicate grants are harmless
@Override
public void becomeLeader() {
  if (leading.compareAndSet(false, true)) {
    doLeaderWork();
  }
}

Prevention

When it happens

Trigger: Curator's LeaderLatch re-delivers the isLeader callback — typically when the latch is recreated after a session event while the node still holds leadership, or duplicate listener registrations on the same executor.

Common situations: ZK session reconnection where leadership was retained, latch stop-and-recreate races, or code paths that register the listener twice.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/97dda766a4aad07f. Report an issue: GitHub.

Appendix: source

Thrown at server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java:98

  private LeaderLatch createNewLeaderLatchWithListener()
  {
    final LeaderLatch newLeaderLatch = createNewLeaderLatch();

    newLeaderLatch.addListener(
        new LeaderLatchListener()
        {
          @Override
          public void isLeader()
          {
            try {
              if (newLeaderLatch.getState().equals(LeaderLatch.State.CLOSED)) {
                log.warn("I'm being asked to become leader, but the latch is CLOSED. Ignored event.");
                return;
              }

              if (leader) {
                log.warn("I'm being asked to become leader. But I am already the leader. Ignored event.");
                return;
              }

              leader = true;
              term.incrementAndGet();
              listener.becomeLeader();
            }
            catch (Exception ex) {
              log.makeAlert(ex, "listener becomeLeader() failed. Unable to become leader").emit();
              notLeader();
            }
          }

          @Override
          public void notLeader()
          {
            try {
              if (!leader) {

View on GitHub (pinned to 9b90983fd2)