aeron-io/aeron · error · ClusterException

log publication is closed

Error message

log publication is closed

What it means

LogPublisher.checkResult inspects the return position of Publication.offer/tryClaim on the cluster log publication. Aeron's Publication returns CLOSED when the underlying publication has been closed; appending to a closed log is impossible, so a ClusterException is thrown. In a cluster this effectively means this member can no longer act as leader/appender.

Solutions

  1. Ensure the publication is not closed before appending (check publication.isClosed())
  2. Verify the leadership/election lifecycle: only the current leader should hold an open log publication
  3. Check that the media driver / archive was not stopped while the cluster is appending
  4. Increase logging around publication close to find who closed it prematurely

Example fix

// before
logPublisher.appendMessage(buffer, offset, length, nowNs);
// after
if (!publication.isClosed()) {
    logPublisher.appendMessage(buffer, offset, length, nowNs);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (publication.isClosed()) { /* re-establish leadership/publication first */ }

Type guard

boolean canAppend(Publication p) { return p != null && !p.isClosed(); }

Try / catch

try { publisher.appendMessage(...); } catch (ClusterException e) { /* election lost / shutdown: stop appending */ }

Prevention

When it happens

Trigger: Any append attempt (appendMessage, appendSessionOpen, appendSessionClose, appendTimer, appendClusterAction, appendNewLeadershipTermEvent) after the log Publication was closed — e.g. after a leadership change closed the old publication, or after stop/close of the cluster media driver.

Common situations: A leadership transition or election closed the publication while the old leader still tried to append; calling into the cluster API during shutdown; a race between closing the publication and pending appends.

Related errors


AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12). Data as JSON: /api/errors/2d0c76e1afca0b73. Report an issue: GitHub.

Appendix: source

Thrown at aeron-cluster/src/main/java/io/aeron/cluster/LogPublisher.java:325

                    .timeUnit(ClusterClock.map(timeUnit))
                    .appVersion(appVersion);

                bufferClaim.commit();
                return true;
            }

            checkResult(position, publication);
        }
        while (--attempts > 0);

        return false;
    }

    private static void checkResult(final long position, final Publication publication)
    {
        if (Publication.CLOSED == position)
        {
            throw new ClusterException("log publication is closed");
        }

        if (Publication.MAX_POSITION_EXCEEDED == position)
        {
            throw new ClusterException(
                "log publication at max position: term-length=" + publication.termBufferLength());
        }
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString()
    {
        return "LogPublisher{" +
            "destinationChannel='" + destinationChannel + '\'' +
            '}';

View on GitHub (pinned to 6d60124e15)