{"record":{"id":"1d09385ce6480922","repo":"aeron-io/aeron","slug":"publication-at-max-position-term-length-publication-1d0938","errorCode":null,"errorMessage":"publication at max position: term-length=${publication.termBufferLength()}","messagePattern":"publication at max position: term-length=(.+?)","errorType":"console","errorClass":"ClusterException","httpStatus":null,"severity":"error","filePath":"aeron-cluster/src/main/java/io/aeron/cluster/service/SnapshotTaker.java","lineNumber":196,"sourceCode":"     *\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();\n        invokeAgentClient();\n        idleStrategy.idle();\n    }\n\n    /**","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-cluster/src/main/java/io/aeron/cluster/service/SnapshotTaker.java#L178-L214","documentation":"checkResult received Publication.MAX_POSITION_EXCEEDED from offer/tryClaim, meaning the snapshot publication reached the terminal position of its term buffer arithmetic (64-bit position space for the term-length configuration). Snapshot publishing cannot continue safely at that position, so the taker throws with the configured term buffer length for diagnosis.","triggerScenarios":"checkResultAndIdle is called after offer/tryClaim returned Publication.MAX_POSITION_EXCEEDED — the publication advanced beyond the maximum representable position for its term-length configuration.","commonSituations":"Extremely long-lived publications with tiny term buffers and unbounded data, snapshot publications reused far beyond intended volume, or position bookkeeping corruption.","solutions":["Close and recreate the publication (start a new snapshot/publication at a fresh position)","Increase the term-length/term-buffer-length configuration to extend the position range","Audit for position bookkeeping bugs that advance the publication position incorrectly"],"exampleFix":"// before\ndefaultTermBufferLength(64 * 1024)\n// after\ndefaultTermBufferLength(1024 * 1024)","handlingStrategy":"try-catch","validationCode":"// Recreate publications well before position exhaustion\nif (publication.position() > Long.MAX_VALUE - margin) { recreatePublication(); }","typeGuard":null,"tryCatchPattern":"try { snapshotTaker.snapshot(...); } catch (ClusterException e) { startNewSnapshotWithFreshPublication(); }","preventionTips":["Use adequately sized term buffers for long-lived publications","Recreate publications instead of reusing them indefinitely","Monitor publication position growth"],"tags":["aeron-cluster","snapshot","publication","position-limit"],"backgroundTag":"value-out-of-range","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"}