apache/druid · warning

I'm being asked to stop being leader. But I am not the…

Error message

I'm being asked to stop being leader. But I am not the leader. Ignored event.

What it means

CuratorDruidLeaderSelector's notLeader() listener callback fired while the local `leader` flag was false, meaning Curator reported a leadership loss for a node that does not consider itself leader. The event is ignored with a warning since there is nothing to relinquish.

Solutions

  1. Usually benign — the node already relinquished leadership; no action needed.
  2. If seen frequently, check ZK session stability and network partition logs.
  3. Confirm stopLeadership lifecycle ordering: unregisterListener() should stop the executor only after the service finished handling the last notLeader event.
  4. Check for overlapping latch instances (old latch callbacks still attached) if the warning appears after normal leader handoff.
Defensive patterns

Strategy: try-catch

Try / catch

// make notLeader handling idempotent
@Override
public void stopBeingLeader() {
  if (leading.compareAndSet(true, false)) {
    cleanupLeaderState();
  }
}

Prevention

When it happens

Trigger: A notLeader event delivered twice, or after the leader flag was already cleared by an earlier notLeader call — e.g. latch close during stopAndCreateNewLeaderLatch() firing the listener again, or events racing during shutdown.

Common situations: ZK session loss causing multiple latch callbacks, rapid leader flapping, or shutdown where the latch closes and Curator emits a final notLeader notification.

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/070bc8521949c685. Report an issue: GitHub.

Appendix: source

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

                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) {
                log.warn("I'm being asked to stop being leader. But I am not the leader. Ignored event.");
                return;
              }

              leader = false;
              // give others a chance to become leader.
              stopAndCreateNewLeaderLatch();
              listener.stopBeingLeader();
              startLeaderLatch();
            }
            catch (Throwable ex) {
              // Shutdown the service since it is now in a non-deterministic state and might never recover
              log.makeAlert(ex, "listener.stopBeingLeader() failed. Shutting down service.").emit();
              System.exit(1);
            }
          }
        },
        listenerExecutor
    );

View on GitHub (pinned to 9b90983fd2)