apache/pulsar · critical · IOException

Failed to open state table for function ${tenant}/${namespac

Error message

Failed to open state table for function ${tenant}/${namespace}/${name}

What it means

Thrown by BKStateStoreProviderImpl.openStateTable when the BookKeeper-backed state table for a function cannot be opened. Two variants: a timeout wrapped in a RuntimeException, and a generic IOException when opening fails for any other reason. The state table is the keyed-state storage used by functions for stateful processing (e.g. windowing, count state).

Source

Thrown at pulsar-functions/instance/src/main/java/org/apache/pulsar/functions/instance/state/BKStateStoreProviderImpl.java:199

        while (openSw.elapsed(TimeUnit.MINUTES) < 1) {
            try {
                return result(client.openTable(name), 1, TimeUnit.MINUTES);
            } catch (InternalServerException ise) {
                log.warn()
                        .attr("tenant", tenant)
                        .attr("namespace", namespace)
                        .attr("name", name)
                        .attr("message", ise.getMessage())
                        .log("Encountered internal server on opening state table,"
                                + " re-attempt in 100 milliseconds");
                TimeUnit.MILLISECONDS.sleep(100);
            } catch (TimeoutException e) {
                throw new RuntimeException(
                        "Failed to open state table for function " + tenant + "/" + namespace + "/" + name
                                + " within timeout period", e);
            }
        }
        throw new IOException("Failed to open state table for function " + tenant + "/" + namespace + "/" + name);
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T extends StateStore> T getStateStore(String tenant, String namespace, String name) throws Exception {
        // we defer creation of the state table until a java instance is running here.
        createStateTable(stateStorageServiceUrl, tenant, namespace, name);
        Table<ByteBuf, ByteBuf> table = openStateTable(tenant, namespace, name);
        return (T) new BKStateStoreImpl(tenant, namespace, name, table);
    }

    @Override
    public void cleanUp(String tenant, String namespace, String name) throws Exception {
        StorageAdminClient storageAdminClient = new SimpleStorageAdminClientImpl(
                StorageClientSettings.newBuilder().serviceUri(stateStorageServiceUrl).build(),
                ClientResources.create().scheduler());
        String tableNs = FunctionCommon.getStateNamespace(tenant, namespace);
        storageAdminClient.deleteStream(tableNs, name).whenComplete((res, throwable) -> {

View on GitHub (pinned to 820761864e)

Solutions

  1. Verify the BookKeeper service is reachable from the function worker and healthy (bookies up, enough writable bookies).
  2. Check metadata store (ZooKeeper) connectivity and configuration of the state storage service.
  3. Increase the state table open timeout or investigate why table creation is slow (disk pressure, network latency).
  4. Inspect worker logs for the underlying cause; if a previous partial creation corrupted the table, delete the stale state table and restart the function.

Example fix

// before: function fails at startup with IOException
// after: ensure state storage configured and bookies healthy
//   broker.conf: stateStorageServiceImpl=org.apache.pulsar.functions.instance.state.PulsarMetadataStoreStateStoreProviderImpl
//   verify: pulsar-admin bookies list-bookies
Defensive patterns

Strategy: retry

Validate before calling

// check bookies and metadata store before starting the function
pulsar-admin bookies list-bookies
pulsar-admin brokers get-runtime-config | grep stateStorage

Try / catch

try {
  stateStore = provider.openStateTable(tenant, ns, name);
} catch (RuntimeException | IOException e) {
  log.error("state table open failed", e);
  // backoff and retry, then fail the function
}

Prevention

When it happens

Trigger: Calling openStateTable (via the `table` lambda) when the BookKeeper table service cannot create/open the state table within the timeout (TimeoutException), or fails outright (any other failure producing IOException).

Common situations: BookKeeper cluster unreachable or overloaded; metadata store (ZooKeeper) connectivity problems; the state table already exists with an incompatible format; slow disk/network causing creation to exceed the timeout.

Related errors


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