Monedula

Markdown

Part VI · Reference

Kafka troubleshooting

CoordinatorNotAvailableException (COORDINATOR_NOT_AVAILABLE)

Kafka error · COORDINATOR_NOT_AVAILABLE · retriable

org.apache.kafka.common.errors.CoordinatorNotAvailableException

The broker answered COORDINATOR_NOT_AVAILABLE (error code 15) because the coordinator for the consumer group cannot serve right now. Usually the partition of the internal topic __consumer_offsets that holds the group does not exist yet, has no live leader, or cannot take writes. The consumer looks the coordinator up again and retries; if the error does not stop, fix that internal topic.

Reproduce it in the playground

The moment it happensProduce is rejected; consumers and the group stop. t+2.550s

WarpStream's docs say that without the control plane an Agent rejects produce and fails every request that needs the control plane. At 2550 p-a's k5 and p-c's k6 are rejected at once with REQUEST_TIMED_OUT, and nothing enters an Agent's buffer. At 2400 c1's fetch failed with REQUEST_TIMED_OUT on every partition, because the list of files to read comes from the control plane, and its offset commit failed with COORDINATOR_NOT_AVAILABLE (the simulator's choice of code), because the control plane coordinates the consumer groups. c1 keeps its partitions but reads and commits nothing.

Open at this step: step 3, Produce is rejected; consumers and the group stop

What it means

Every consumer group is managed by a group coordinator: the broker that leads the partition of __consumer_offsets the group id hashes to. A client finds it with a FindCoordinator request, then sends its joins, heartbeats and offset commits there. In Apache Kafka 4.4 a broker answers FindCoordinator with COORDINATOR_NOT_AVAILABLE in three cases: the internal topic does not exist yet (the broker then asks the controller to create it, and the client has to ask again), the topic's metadata carries an error, or the group's partition has no live leader. The coordinator returns the same code while its service is not active, and when a commit or a group change cannot be written to __consumer_offsets because the write failed with NOT_ENOUGH_REPLICAS, REQUEST_TIMED_OUT or UNKNOWN_TOPIC_OR_PARTITION. The exception's javadoc adds the transactional case: a transaction coordinator returns it when its log, __transaction_state, is under-replicated or an append to it times out. Two neighbouring codes mean something else: COORDINATOR_LOAD_IN_PROGRESS says the coordinator is still loading the group's state after a leader change, and NOT_COORDINATOR says the client asked a broker that is not the coordinator. WarpStream, a Kafka-compatible system, keeps its consumer groups in its hosted control plane rather than in a topic; the simulator answers group calls with COORDINATOR_NOT_AVAILABLE while that control plane is unreachable, which is its own choice of code. Scenarios 10.1.4 and 10.1.5 show it. Nisshi (formerly Tansu), a Kafka-compatible broker, has no __consumer_offsets topic: its storage engine keeps the group state and the committed offsets, and FindCoordinator answers the broker that received it. While the engine is unavailable, Nisshi 0.8.2 answers offset commits and group requests with COORDINATOR_NOT_AVAILABLE. Scenario 12.1.6 shows it on the PostgreSQL engine.

Likely causes, most common first

  1. A new cluster cannot create __consumer_offsets. The topic is created on first use with offsets.topic.replication.factor replicas (3 by default) and offsets.topic.num.partitions partitions (50 by default). On a development cluster with fewer brokers than that replication factor the controller cannot place the replicas, so the topic is never created and every consumer group keeps getting COORDINATOR_NOT_AVAILABLE. Transactions hit the same wall with transaction.state.log.replication.factor.
  2. The group's partition of __consumer_offsets has no leader. The brokers that hold the replicas of that partition are down or cut off, so no broker can coordinate the groups that hash to it. Groups on other partitions carry on. The error clears when a replica comes back and is elected leader.
  3. Writes to __consumer_offsets fail. The coordinator writes offset commits and group changes to the internal topic and waits for its in-sync replicas. With fewer in-sync replicas than min.insync.replicas, or replication slower than the coordinator's write timeout, the write fails with NOT_ENOUGH_REPLICAS or REQUEST_TIMED_OUT and the client gets COORDINATOR_NOT_AVAILABLE instead.
  4. The coordinator broker is starting or shutting down. While the coordinator service on a broker is not active, it refuses group requests with this code. A rolling restart produces a short burst of it; the clients find the new coordinator and go on.
  5. WarpStream (not Apache Kafka): the control plane is unreachable. WarpStream runs consumer group coordination in its hosted control plane. While the control plane is unreachable, group calls fail; WarpStream's docs name no error code, so the simulator answers offset commits and group joins with COORDINATOR_NOT_AVAILABLE. The group keeps its assignment, commits nothing during the outage, and commits again once the control plane is back. Ripcord does not change this: it lets the Agents keep taking produce during the outage, but WarpStream's Ripcord page says consumers stop, and the simulator fails their group calls the same way.
  6. Nisshi: its storage engine is unavailable. On a Nisshi cluster the group state and committed offsets are in PostgreSQL, or in S3 on its experimental engine. While that store is down, offset commits and group changes get COORDINATOR_NOT_AVAILABLE; once it is back they succeed again, and asking another broker does not help.

How to fix it

  • Describe the internal topic with kafka-topics.sh --describe --topic __consumer_offsets and look for partitions with no leader or a short ISR; if the topic is missing, check that the cluster has at least offsets.topic.replication.factor live brokers.
  • On a single-broker or two-broker development cluster, set offsets.topic.replication.factor (and transaction.state.log.replication.factor) to the broker count before the first group or transaction uses the cluster. The setting applies when the topic is created; to change the replication factor of an existing topic, reassign its partitions.
  • Bring back the brokers that hold the leaderless partition, and keep the internal topics on brokers in different racks or zones so one failure cannot take a partition down.
  • Let the client retry. With commitAsync(), treat a RetriableCommitFailedException as a commit that a later one will cover, rather than resending an old offset.
  • On WarpStream, bring the control plane back or wait for it: the consumers retry and commit again on their own.
  • On Nisshi, bring the storage engine back; the consumer commits again at its next poll.

What not to do

  • Deleting __consumer_offsets, or recreating it, to clear the error: it holds every group's committed offsets, and the groups lose their positions.

Does the client retry it?

Yes, the client retries. COORDINATOR_NOT_AVAILABLE (error code 15) is retriable: CoordinatorNotAvailableException extends RefreshRetriableException, so the consumer marks its coordinator unknown, looks it up again and retries. commitSync() keeps retrying until its timeout runs out; commitAsync() hands its callback a RetriableCommitFailedException, and a later commit covers the same offsets. The error reaches the application only when the cause outlasts those timeouts.

Reproduce it in the simulator

Sources

All troubleshooting pages