apache/pulsar · error · IllegalArgumentException

The broker ${brokerAddress} is not among the shared broker p

Error message

The broker ${brokerAddress} is not among the shared broker pools for the uncontrolled namespace.

What it means

When a namespace has NO namespace-isolation policy (uncontrolled), every broker serving it must belong to a shared broker pool. getBrokerAssignment() throws IllegalArgumentException if the given broker matches no shared pool regex, because an uncontrolled namespace cannot be served by a broker outside the shared pool.

Source

Thrown at pulsar-common/src/main/java/org/apache/pulsar/common/policies/impl/NamespaceIsolationPolicies.java:153

     * @param nsPolicy
     *            The namespace name
     * @param brokerAddress
     *            The broker address is the format of host:port
     * @return The broker assignment: {primary, secondary, shared}
     */
    private BrokerAssignment getBrokerAssignment(NamespaceIsolationPolicy nsPolicy, String brokerAddress) {
        if (nsPolicy != null) {
            if (nsPolicy.isPrimaryBroker(brokerAddress)) {
                return BrokerAssignment.primary;
            } else if (nsPolicy.isSecondaryBroker(brokerAddress)) {
                return BrokerAssignment.secondary;
            }
            throw new IllegalArgumentException("The broker " + brokerAddress
                    + " is not among the assigned broker pools for the controlled namespace.");
        }
        // Only uncontrolled namespace will be assigned to the shared pool
        if (!this.isSharedBroker(brokerAddress)) {
            throw new IllegalArgumentException("The broker " + brokerAddress
                    + " is not among the shared broker pools for the uncontrolled namespace.");
        }
        return BrokerAssignment.shared;
    }

    public void assignBroker(NamespaceName nsname, BrokerStatus brkStatus, SortedSet<BrokerStatus> primaryCandidates,
            SortedSet<BrokerStatus> secondaryCandidates, SortedSet<BrokerStatus> sharedCandidates) {
        NamespaceIsolationPolicy nsPolicy = this.getPolicyByNamespace(nsname);
        BrokerAssignment brokerAssignment = this.getBrokerAssignment(nsPolicy, brkStatus.getBrokerAddress());
        if (brokerAssignment == BrokerAssignment.primary) {
            // Only add to candidates if allowed by policy
            if (nsPolicy != null && nsPolicy.isPrimaryBrokerAvailable(brkStatus)) {
                primaryCandidates.add(brkStatus);
            }
        } else if (brokerAssignment == BrokerAssignment.secondary) {
            secondaryCandidates.add(brkStatus);
        } else if (brokerAssignment == BrokerAssignment.shared) {
            sharedCandidates.add(brkStatus);

View on GitHub (pinned to 820761864e)

Solutions

  1. Add the broker's URL pattern to the 'shared' regex list of the namespace isolation policies
  2. Make the shared regex broader (e.g. match all brokers in the cluster) so unassigned brokers fall into the shared pool
  3. Align broker advertised addresses with the configured patterns (consistent hostnames)
  4. If isolation was intentional, attach a policy for that namespace so it is treated as controlled

Example fix

// before
"shared": ["shared-broker-.*"]   // regular brokers don't match
// after
"shared": [".*"]  // any broker can serve uncontrolled namespaces
Defensive patterns

Strategy: validation

Validate before calling

// For uncontrolled namespaces, ensure broker is in a shared pool
NamespaceIsolationPolicies policies = load();
if (policies.getPolicyByNamespace(ns) == null && !policies.isSharedBroker(brokerUrl)) {
    throw new IllegalStateException("Broker " + brokerUrl + " is not in any shared pool");
}

Type guard

static boolean brokerShareable(NamespaceIsolationPolicies p, String url) {
    return p != null && p.isSharedBroker(url);
}

Try / catch

try {
    BrokerAssignment a = policies.brokerAssignment(ns, brokerUrl);
} catch (IllegalArgumentException e) {
    log.warn("Uncontrolled namespace {} served by non-shared broker {}: {}", ns, brokerUrl, e.getMessage());
    // fall back to shared-pool broker selection
}

Prevention

When it happens

Trigger: Calling brokerAssignment/getBrokerAssignment for a broker on a namespace without an isolation policy, where the broker's URL matches none of the shared regexes in NamespaceIsolationPolicies.

Common situations: Cluster isolation config lists primary/secondary pools but omits 'shared' patterns; broker hostname doesn't match the shared regex (IP vs hostname); isolation data loaded from ZK is stale relative to running brokers.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/3e0b12bf25233468. Report an issue: GitHub.