{"record":{"id":"b6e4d813f1123b84","repo":"aeron-io/aeron","slug":"publication-is-closed-snapshottaker","errorCode":null,"errorMessage":"publication is closed","messagePattern":"publication is closed","errorType":"console","errorClass":"ClusterException","httpStatus":null,"severity":"error","filePath":"aeron-cluster/src/main/java/io/aeron/cluster/service/SnapshotTaker.java","lineNumber":191,"sourceCode":"        }\n    }\n\n    /**\n     * Check the result of offering to a publication when writing a snapshot.\n     *\n     * @param position    of an offer or try claim to a publication.\n     * @param publication on which the offer or try claim was attempted.\n     */\n    protected static void checkResult(final long position, final Publication publication)\n    {\n        if (Publication.NOT_CONNECTED == position)\n        {\n            throw new ClusterException(\"publication is not connected\");\n        }\n\n        if (Publication.CLOSED == position)\n        {\n            throw new ClusterException(\"publication is closed\");\n        }\n\n        if (Publication.MAX_POSITION_EXCEEDED == position)\n        {\n            throw new ClusterException(\"publication at max position: term-length=\" + publication.termBufferLength());\n        }\n    }\n\n    /**\n     * Check the result of offering to a publication when writing a snapshot and then idle after invoking the client\n     * agent if necessary.\n     *\n     * @param position of an offer or try claim to a publication.\n     */\n    protected void checkResultAndIdle(final long position)\n    {\n        checkResult(position, publication);\n        checkInterruptStatus();","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-cluster/src/main/java/io/aeron/cluster/service/SnapshotTaker.java#L173-L209","documentation":"checkResult detects that the snapshot publication's underlying publication was CLOSED (Publication.CLOSED returned from offer/tryClaim). Once closed, no further snapshot data can be published and the snapshot cannot complete, so the taker throws immediately.","triggerScenarios":"checkResultAndIdle is called after offer/tryClaim returned Publication.CLOSED — the Publication object was closed, typically because the cluster container or client was being torn down mid-snapshot.","commonSituations":"Shutting down or aborting a clustered service while a snapshot is in flight, Aeron client close racing with SnapshotTaker, or an error elsewhere causing the publication to be closed by the client conductor.","solutions":["Do not close the Aeron client or publication while snapshotting; complete or cancel the snapshot first","Check service logs for the earlier error that caused the publication to close","Re-run the snapshot after the container has cleanly restarted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure the publication is still open before snapshotting\nif (publication.isClosed()) { recreatePublication(); }","typeGuard":null,"tryCatchPattern":"try { snapshotTaker.snapshot(...); } catch (ClusterException e) { abortSnapshotAndShutdownCleanly(); }","preventionTips":["Order shutdown: finish/cancel snapshot before closing the Aeron client","Avoid racing service abort with SnapshotTaker writes","Log and fix the root cause that closed the publication"],"tags":["aeron-cluster","snapshot","publication","lifecycle"],"backgroundTag":"broken-pipe","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}