{"record":{"id":"77ad0339fdd385ad","repo":"aeron-io/aeron","slug":"failed-to-send-stop-all-replays-request","errorCode":null,"errorMessage":"failed to send stop all replays request","messagePattern":"failed to send stop all replays request","errorType":"exception","errorClass":"ArchiveException","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/client/AeronArchive.java","lineNumber":1210,"sourceCode":"\n    /**\n     * Stop all replay sessions for a given recording id or all replays in general.\n     *\n     * @param recordingId to stop replay for or {@link Aeron#NULL_VALUE} for all replays.\n     */\n    public void stopAllReplays(final long recordingId)\n    {\n        lock.lock();\n        try\n        {\n            ensureConnected();\n            ensureNotReentrant();\n\n            lastCorrelationId = aeron.nextCorrelationId();\n\n            if (!archiveProxy.stopAllReplays(recordingId, lastCorrelationId, controlSessionId))\n            {\n                throw new ArchiveException(\"failed to send stop all replays request\");\n            }\n\n            pollForResponse(lastCorrelationId);\n        }\n        finally\n        {\n            lock.unlock();\n        }\n    }\n\n    /**\n     * Replay a length in bytes of a recording from a position and for convenience create a {@link Subscription}\n     * to receive the replay. If the position is {@link #NULL_POSITION} then the stream will be replayed from the start.\n     *\n     * @param recordingId    to be replayed.\n     * @param position       from which the replay should begin or {@link #NULL_POSITION} if from the start.\n     * @param length         of the stream to be replayed or {@link AeronArchive#REPLAY_ALL_AND_FOLLOW} to follow a live\n     *                       recording. Use {@link AeronArchive#REPLAY_ALL_AND_STOP} to read up the available limit","sourceCodeStart":1192,"sourceCodeEnd":1228,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/client/AeronArchive.java#L1192-L1228","documentation":"stopAllReplays sends a STOP_ALL_REPLAYS request for a recording. If ArchiveProxy.stopAllReplays returns false — the control-request publication is not connected or the offer fails — no request reached the archive and this ArchiveException is thrown.","triggerScenarios":"Calling stopAllReplays(recordingId) during an archive outage, network partition, control-stream backpressure, or after the client's control session publication has closed (e.g. archive restart invalidated the session).","commonSituations":"Failover/cleanup logic that stops all replays while the archive is mid-restart; batch jobs issuing many stop requests that backpressure the single control stream; stale AeronArchive handles kept across redeploys.","solutions":["Verify the archive process is running and the control channel endpoint is reachable.","Reconnect the session (AeronArchive.connect) and retry stopAllReplays.","Retry with exponential backoff if backpressure is likely transient.","Log recordingId and correlationId (lastCorrelationId field) for post-mortem when retries fail."],"exampleFix":"// before\narchive.stopAllReplays(recordingId);\n\n// after\ntry {\n    archive.stopAllReplays(recordingId);\n} catch (ArchiveException e) {\n    archive.close();\n    archive = AeronArchive.connect(archiveCtx);\n    archive.stopAllReplays(recordingId);\n}","handlingStrategy":"retry","validationCode":"if (recordingId <= 0) throw new IllegalArgumentException(\"invalid recordingId\");\nboolean connected = archive != null && !archive.isClosed() && archive.state() == AeronArchive.State.CONNECTED;","typeGuard":"boolean canStopAll(AeronArchive a) { return a != null && !a.isClosed() && a.state() == AeronArchive.State.CONNECTED; }","tryCatchPattern":"try {\n    archive.stopAllReplays(recordingId);\n} catch (ArchiveException e) {\n    archive = AeronArchive.connect(archiveCtx);\n    retryWithBackoff(() -> archive.stopAllReplays(recordingId));\n}","preventionTips":["Check archive health before bulk stop operations.","Space out batches of control requests to avoid backpressuring the single control stream.","Reconnect stale sessions after archive redeploys.","Record lastCorrelationId for support/debugging."],"tags":["aeron","archive","replay","network"],"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"}