Skip to content
Latchkey

Pulsar "Failed to get partitioned topic metadata" in CI

Before producing or consuming, the Pulsar client looks up a topic to learn whether it is partitioned and which broker owns it. This lookup failed: the broker was not ready, the service URL was wrong, or the topic lookup timed out.

What this error means

The client fails with "Failed to get partitioned topic metadata: ... " often wrapping a lookup timeout or connection error during client setup.

Terminal
org.apache.pulsar.client.api.PulsarClientException:
Failed to get partitioned topic metadata: java.util.concurrent.TimeoutException

Common causes

The broker was not ready for lookups

The lookup to resolve topic ownership runs against a broker that has not finished startup, so it times out.

Wrong service URL for the lookup

A serviceUrl that does not match the broker binary address makes the lookup unreachable.

How to fix it

Wait for broker health before client setup

Gate client creation on the broker health admin endpoint so lookups succeed.

Terminal
until curl -sf http://localhost:8080/admin/v2/brokers/health; do
  echo "waiting for pulsar broker"; sleep 3
done

Use the correct binary serviceUrl

Point the client at the mapped 6650 address the broker advertises.

.github/workflows/ci.yml
env:
  PULSAR_SERVICE_URL: pulsar://localhost:6650

How to prevent it

  • Wait for the broker health endpoint before creating clients.
  • Keep serviceUrl aligned with the mapped binary port.
  • Allow a generous lookup timeout for slow first startup.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →