{"record":{"id":"fd66951754b5d89a","repo":"apache/pulsar","slug":"error-compacting-s","errorCode":null,"errorMessage":"Error compacting: %s","messagePattern":"Error compacting: (.+?)","errorType":"exception","errorClass":"PulsarAdminException","httpStatus":null,"severity":"error","filePath":"pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java","lineNumber":683,"sourceCode":"                while (wait && status.status == LongRunningProcessStatus.Status.RUNNING) {\n                    Thread.sleep(1000);\n                    status = getPersistentTopics().compactionStatus(persistentTopic);\n                }\n\n                switch (status.status) {\n                case NOT_RUN:\n                    System.out.println(\"Compaction has not been run for \" + persistentTopic\n                                       + \" since broker startup\");\n                    break;\n                case RUNNING:\n                    System.out.println(\"Compaction is currently running\");\n                    break;\n                case SUCCESS:\n                    System.out.println(\"Compaction was a success\");\n                    break;\n                case ERROR:\n                    System.out.println(\"Error in compaction\");\n                    throw new PulsarAdminException(\"Error compacting: \" + status.lastError);\n                }\n            } catch (InterruptedException e) {\n                throw new PulsarAdminException(e);\n            }\n        }\n    }\n}\n","sourceCodeStart":665,"sourceCodeEnd":691,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdPersistentTopics.java#L665-L691","documentation":"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.","triggerScenarios":"Running `pulsar-admin topics compact` and the asynchronous compaction on the broker ends in ERROR state; status.lastError contains the broker-side exception message.","commonSituations":"Broker cannot read bookkeeper ledgers (ledger deleted/corrupted), insufficient disk on bookies, topic concurrently deleted during compaction, or broker-side permissions/storage errors.","solutions":["Read the embedded lastError message to find the broker-side root cause","Check broker logs around the compaction time for the full stack trace","Verify bookkeeper ledgers for the topic are intact and bookies have capacity","Re-run compaction after fixing the underlying issue"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    topics.compact(topic).get();\n} catch (org.apache.pulsar.client.admin.PulsarAdminException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Error compacting:\")) {\n        // inspect broker error and bookkeeper health, then retry after fix\n    }\n}","preventionTips":["Monitor bookie disk usage before running compaction","Ensure ledgers are not deleted while compaction runs (watch retention policies)","Check broker logs for the full cause behind lastError"],"tags":["compaction","broker","bookkeeper"],"backgroundTag":"server-side-compaction-failure","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}