{"record":{"id":"d0fe41729f3864a0","repo":"aeron-io/aeron","slug":"failed-to-send-stop-replication-request","errorCode":null,"errorMessage":"failed to send stop replication request","messagePattern":"failed to send stop replication request","errorType":"exception","errorClass":"ArchiveException","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/client/AeronArchive.java","lineNumber":2102,"sourceCode":"    /**\n     * Stop a replication session by id returned from {@link #replicate(long, long, int, String, String)}.\n     *\n     * @param replicationId to stop replication for.\n     * @see #replicate(long, long, int, String, String)\n     */\n    public void stopReplication(final long replicationId)\n    {\n        lock.lock();\n        try\n        {\n            ensureConnected();\n            ensureNotReentrant();\n\n            lastCorrelationId = aeron.nextCorrelationId();\n\n            if (!archiveProxy.stopReplication(replicationId, lastCorrelationId, controlSessionId))\n            {\n                throw new ArchiveException(\"failed to send stop replication request\");\n            }\n\n            pollForResponse(lastCorrelationId);\n        }\n        finally\n        {\n            lock.unlock();\n        }\n    }\n\n\n    /**\n     * Attempt to stop a replication session by id returned from {@link #replicate(long, long, int, String, String)}.\n     *\n     * @param replicationId to stop replication for.\n     * @return {@code true} if the replication was stopped, false if the replication is not active.\n     * @see #replicate(long, long, int, String, String)\n     */","sourceCodeStart":2084,"sourceCodeEnd":2120,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/client/AeronArchive.java#L2084-L2120","documentation":"Thrown when a stopReplication request could not be offered to the archive control publication. ArchiveProxy.stopReplication returned false, so the archive never received the instruction to stop the given replicationId. The replication keeps running server-side; this is purely a request-delivery failure.","triggerScenarios":"Calling AeronArchive.stopReplication(replicationId) while the control session publication is closed, the archive is unreachable, or the publication is persistently back-pressured so the offer fails after retries.","commonSituations":"Cancelling a replication during an archive restart; teardown code in a finally block reusing a dead AeronArchive; network interruption between client and destination archive when stopping cross-DC replication.","solutions":["Reconnect the archive session and re-issue stopReplication with the same replicationId.","Verify the archive is still running; if it was restarted, the replication is already gone and the stop can be skipped.","Check the control channel and Aeron error log for publication close/back-pressure events.","Implement idempotent cleanup: on send failure, reconnect, then verify via listReplications whether the replication still exists before stopping.","Avoid long-lived idle AeronArchive handles in teardown paths; recreate the session before cleanup operations."],"exampleFix":"// before\narchive.stopReplication(replicationId);\n// after\ntry {\n    archive.stopReplication(replicationId);\n} catch (ArchiveException e) {\n    if (e.message().contains(\"failed to send\")) {\n        archive = AeronArchive.connect(ctx);\n        archive.stopReplication(replicationId);\n    } else {\n        throw e;\n    }\n}","handlingStrategy":"try-catch","validationCode":"if (archive == null || archive.context().isClosed()) { archive = AeronArchive.connect(ctx); }","typeGuard":"static boolean isSendFailure(ArchiveException e) { return e.getMessage() != null && e.getMessage().contains(\"failed to send\"); }","tryCatchPattern":"try { archive.stopReplication(replicationId); } catch (ArchiveException e) { if (isSendFailure(e)) { archive = reconnect(archive); archive.stopReplication(replicationId); } else { throw e; } }","preventionTips":["Recreate the session before cleanup/teardown operations rather than reusing possibly-dead handles.","Make teardown idempotent: verify replication state after a failed stop.","Avoid stopping many replications in a tight loop to prevent back-pressure.","Watch for archive restarts and treat unknown replication after restart as success."],"tags":["aeron-archive","replication","control-session","ipc-offer-failed"],"backgroundTag":"api-request-failed","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"}