aeron-io/aeron · error · AeronException
failed to write remove publication command
Error message
failed to write remove publication command
What it means
DriverProxy.removePublication() throws AeronException when tryClaim(REMOVE_PUBLICATION, length) cannot write the removal command to the client-to-driver buffer. The library treats an unwritable removal as fatal because the client's release accounting would diverge from the driver's, so it fails fast rather than silently leaking the publication image.
Solutions
- Ensure publications are closed while the driver and client conductor are still healthy — avoid releasing during shutdown races.
- Check the driver conductor for slow listener callbacks that stall command consumption.
- If this occurs at process exit, treat it as secondary: fix the root cause (driver death) and let the driver reclaim orphaned publications.
Example fix
// before
publication.close(); // may throw if driver is gone
// after
try { publication.close(); } catch (AeronException e) { log.warn("driver unavailable during close, ignoring", e); } Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
publication.close();
} catch (AeronException e) {
log.warn("removePublication failed - driver may be down; driver will reclaim", e);
} Prevention
- Close publications before shutting down the driver.
- Keep driver conductor handlers fast so command consumption never stalls.
- Treat close-path exceptions as non-fatal and log them for root-cause analysis.
When it happens
Trigger: Calling Publication.close() (which routes to removePublication) while the command buffer is full and the driver is not consuming; also reachable via Aeron师父 driver shutdown or conductor close racing with release calls.
Common situations: Driver killed while client releases publications in a shutdown hook; heavy command traffic (many add/remove cycles) overflowing the buffer; blocking the driver conductor with a long-running counter/notification handler.
Related errors
- failed to write add publication command
- failed to write add exclusive publication command
- failed to write add subscription command
- failed to write remove subscription command
- failed to write add destination command
AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12).
Data as JSON: /api/errors/f93580b1c07e4b8d.
Report an issue: GitHub.
Appendix: source
Thrown at aeron-client/src/main/java/io/aeron/DriverProxy.java:143
toDriverCommandBuffer.commit(index);
return correlationId;
}
/**
* Instruct the driver to remove a publication by its registration id.
*
* @param registrationId for the publication to be removed.
* @param revoke whether the publication is being revoked.
* @return the correlation id for the command.
*/
public long removePublication(final long registrationId, final boolean revoke)
{
final long correlationId = toDriverCommandBuffer.nextCorrelationId();
final int index = toDriverCommandBuffer.tryClaim(REMOVE_PUBLICATION, RemovePublicationFlyweight.length());
if (index < 0)
{
throw new AeronException("failed to write remove publication command");
}
removePublicationFlyweight
.wrap(toDriverCommandBuffer.buffer(), index)
.revoke(revoke)
.registrationId(registrationId)
.clientId(clientId)
.correlationId(correlationId);
toDriverCommandBuffer.commit(index);
return correlationId;
}
/**
* Instruct the driver to add a subscription.
*
* @param channel uri in string format.View on GitHub (pinned to 6d60124e15)