apache/pulsar · error · PulsarAdminException

Error compacting: %s

Error message

Error compacting: %s

What it means

During compaction the CLI polls the compaction status. When the status transitions to ERROR, the broker-reported lastError is surfaced to the user by throwing PulsarAdminException('Error compacting: <broker error>'). This indicates the compaction itself failed server-side, not a CLI argument problem.

Source

Thrown at pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java:683

                while (wait && status.status == LongRunningProcessStatus.Status.RUNNING) {
                    Thread.sleep(1000);
                    status = getPersistentTopics().compactionStatus(persistentTopic);
                }

                switch (status.status) {
                case NOT_RUN:
                    System.out.println("Compaction has not been run for " + persistentTopic
                                       + " since broker startup");
                    break;
                case RUNNING:
                    System.out.println("Compaction is currently running");
                    break;
                case SUCCESS:
                    System.out.println("Compaction was a success");
                    break;
                case ERROR:
                    System.out.println("Error in compaction");
                    throw new PulsarAdminException("Error compacting: " + status.lastError);
                }
            } catch (InterruptedException e) {
                throw new PulsarAdminException(e);
            }
        }
    }
}

View on GitHub (pinned to 820761864e)

Solutions

  1. Read the embedded lastError message to find the broker-side root cause
  2. Check broker logs around the compaction time for the full stack trace
  3. Verify bookkeeper ledgers for the topic are intact and bookies have capacity
  4. Re-run compaction after fixing the underlying issue
Defensive patterns

Strategy: try-catch

Try / catch

try {
    topics.compact(topic).get();
} catch (org.apache.pulsar.client.admin.PulsarAdminException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("Error compacting:")) {
        // inspect broker error and bookkeeper health, then retry after fix
    }
}

Prevention

When it happens

Trigger: Running `pulsar-admin topics compact` and the asynchronous compaction on the broker ends in ERROR state; status.lastError contains the broker-side exception message.

Common situations: Broker cannot read bookkeeper ledgers (ledger deleted/corrupted), insufficient disk on bookies, topic concurrently deleted during compaction, or broker-side permissions/storage errors.

Related errors


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