{"record":{"id":"f97e942202420976","repo":"aeron-io/aeron","slug":"failed-to-send-delete-detached-segments-request","errorCode":null,"errorMessage":"failed to send delete detached segments request","messagePattern":"failed to send delete detached segments request","errorType":"exception","errorClass":"ArchiveException","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/client/AeronArchive.java","lineNumber":2197,"sourceCode":"     * Delete segments which have been previously detached from a recording.\n     *\n     * @param recordingId to which the operation applies.\n     * @return count of deleted segment files.\n     * @see #detachSegments(long, long)\n     */\n    public long deleteDetachedSegments(final long recordingId)\n    {\n        lock.lock();\n        try\n        {\n            ensureConnected();\n            ensureNotReentrant();\n\n            lastCorrelationId = aeron.nextCorrelationId();\n\n            if (!archiveProxy.deleteDetachedSegments(recordingId, lastCorrelationId, controlSessionId))\n            {\n                throw new ArchiveException(\"failed to send delete detached segments request\");\n            }\n\n            return pollForResponse(lastCorrelationId);\n        }\n        finally\n        {\n            lock.unlock();\n        }\n    }\n\n    /**\n     * Purge (detach and delete) segments from the beginning of a recording up to the provided new start position.\n     * <p>\n     * The new start position must be first byte position of a segment after the existing start position.\n     * <p>\n     * It is not possible to detach segments which are active for recording or being replayed.\n     *\n     * @param recordingId      to which the operation applies.","sourceCodeStart":2179,"sourceCodeEnd":2215,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/client/AeronArchive.java#L2179-L2215","documentation":"Thrown by AeronArchive when the client could not even offer the deleteDetachedSegments request to the archive control publication. The ArchiveProxy send returned false, typically because the publication is not connected or its offer was retried out (backpressure) past the retry budget. No request reached the archive, so the recording's detached segments are not deleted.","triggerScenarios":"Calling AeronArchive.deleteDetachedSegments(recordingId) while the control request publication cannot accept the message: archive is down, control channel disconnected, or send buffer full and offer retries exhausted.","commonSituations":"Archive agent stopped or restarted between session establishment and the call; slow/congested control-channel network; client created with too-short publication retry settings while archive is under load.","solutions":["Check the archive is running and the control channel is connected (subscription.isConnected()) before issuing the request.","Retry deleteDetachedSegments after a short backoff; offer failures are frequently transient backpressure.","Verify controlRequestChannel/streamId configuration matches a live archive control listener.","Capture the ArchiveException, inspect connection state, and reconnect via AeronArchive.connect() if the session is dead."],"exampleFix":"// before\narchive.deleteDetachedSegments(recordingId);\n// after\nif (!archive.controlResponsePoller().subscription().isConnected()) {\n    archive = AeronArchive.connect(ctx); // re-establish session\n}\narchive.deleteDetachedSegments(recordingId);","handlingStrategy":"retry","validationCode":"// pre-check\nif (!archiveProxyPublication.isConnected()) { reconnectArchiveSession(); }","typeGuard":null,"tryCatchPattern":"try {\n    archive.deleteDetachedSegments(recordingId);\n} catch (ArchiveException e) {\n    retryWithBackoff(() -> archive.deleteDetachedSegments(recordingId), 3);\n}","preventionTips":["Monitor archive process health before issuing segment management calls.","Keep archive session reconnection logic centralized in a wrapper.","Avoid issuing control requests during archive maintenance windows."],"tags":["aeron-archive","ipc-send-failure","backpressure"],"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-19T12:17:13.211Z"}