{"record":{"id":"f879aabead81fa6a","repo":"aeron-io/aeron","slug":"failed-to-write-remove-destination-command","errorCode":null,"errorMessage":"failed to write remove destination command","messagePattern":"failed to write remove destination command","errorType":"exception","errorClass":"AeronException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/DriverProxy.java","lineNumber":258,"sourceCode":"\n        return correlationId;\n    }\n\n    /**\n     * Remove a destination from the send channel of an existing MDC Publication.\n     *\n     * @param registrationId  of the Publication.\n     * @param endpointChannel used for the {@link #addDestination(long, String)} command.\n     * @return the correlation id for the command.\n     */\n    public long removeDestination(final long registrationId, final String endpointChannel)\n    {\n        final long correlationId = toDriverCommandBuffer.nextCorrelationId();\n        final int length = DestinationMessageFlyweight.computeLength(endpointChannel.length());\n        final int index = toDriverCommandBuffer.tryClaim(REMOVE_DESTINATION, length);\n        if (index < 0)\n        {\n            throw new AeronException(\"failed to write remove destination command\");\n        }\n\n        destinationMessageFlyweight\n            .wrap(toDriverCommandBuffer.buffer(), index)\n            .registrationCorrelationId(registrationId)\n            .channel(endpointChannel)\n            .clientId(clientId)\n            .correlationId(correlationId);\n\n        toDriverCommandBuffer.commit(index);\n\n        return correlationId;\n    }\n\n    /**\n     * Remove a destination from the send channel of an existing MDC Publication.\n     *\n     * @param publicationRegistrationId  of the Publication.","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/DriverProxy.java#L240-L276","documentation":"DriverProxy.removeDestination() throws AeronException when tryClaim(REMOVE_DESTINATION, length) cannot write the removal command to the client-to-driver command buffer. The driver would then keep the endpoint attached, so Aeron throws instead of returning success and silently diverging from driver state.","triggerScenarios":"Calling Publication.removeDestination(endpointChannel) while the to-driver buffer is full because the driver is stopped, crashed, or its conductor thread is blocked; races with publication close are also possible.","commonSituations":"Tearing down multi-destination publications during application shutdown after the driver already exited; driver thread wedged on a slow notification handler; network-driven driver restart while clients keep adjusting destinations.","solutions":["Perform destination removal while the driver is confirmed running; defer removals queued during an outage.","Wrap removeDestination in try-catch during shutdown paths where driver death is expected.","Investigate driver conductor stalls (long handlers, GC pauses) if the buffer repeatedly fills."],"exampleFix":"// before\npublication.removeDestination(\"aeron:udp?endpoint=host2:40456\");\n// after\ntry { publication.removeDestination(\"aeron:udp?endpoint=host2:40456\"); }\ncatch (AeronException e) { log.warn(\"could not remove destination; driver unavailable\", e); }","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n    publication.removeDestination(endpointChannel);\n} catch (AeronException e) {\n    log.warn(\"removeDestination failed; driver may already be down\", e);\n}","preventionTips":["Remove destinations while the driver is confirmed healthy.","Swallow-and-log this exception in shutdown paths where driver death is expected.","Monitor driver conductor stalls to prevent recurring buffer-full conditions."],"tags":["aeron","driver-communication","ring-buffer-full","destination-management"],"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"}