{"record":{"id":"f93580b1c07e4b8d","repo":"aeron-io/aeron","slug":"failed-to-write-remove-publication-command","errorCode":null,"errorMessage":"failed to write remove publication command","messagePattern":"failed to write remove publication command","errorType":"exception","errorClass":"AeronException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/DriverProxy.java","lineNumber":143,"sourceCode":"        toDriverCommandBuffer.commit(index);\n\n        return correlationId;\n    }\n\n    /**\n     * Instruct the driver to remove a publication by its registration id.\n     *\n     * @param registrationId for the publication to be removed.\n     * @param revoke whether the publication is being revoked.\n     * @return the correlation id for the command.\n     */\n    public long removePublication(final long registrationId, final boolean revoke)\n    {\n        final long correlationId = toDriverCommandBuffer.nextCorrelationId();\n        final int index = toDriverCommandBuffer.tryClaim(REMOVE_PUBLICATION, RemovePublicationFlyweight.length());\n        if (index < 0)\n        {\n            throw new AeronException(\"failed to write remove publication command\");\n        }\n\n        removePublicationFlyweight\n            .wrap(toDriverCommandBuffer.buffer(), index)\n            .revoke(revoke)\n            .registrationId(registrationId)\n            .clientId(clientId)\n            .correlationId(correlationId);\n\n        toDriverCommandBuffer.commit(index);\n\n        return correlationId;\n    }\n\n    /**\n     * Instruct the driver to add a subscription.\n     *\n     * @param channel  uri in string format.","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/DriverProxy.java#L125-L161","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\npublication.close(); // may throw if driver is gone\n// after\ntry { publication.close(); } catch (AeronException e) { log.warn(\"driver unavailable during close, ignoring\", e); }","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    publication.close();\n} catch (AeronException e) {\n    log.warn(\"removePublication failed - driver may be down; driver will reclaim\", e);\n}","preventionTips":["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."],"tags":["aeron","driver-communication","ring-buffer-full","command-buffer"],"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"}