{"record":{"id":"3dbca8b0c66bc176","repo":"aeron-io/aeron","slug":"response-publication-is-at-max-position-session","errorCode":null,"errorMessage":"response publication is at max position: \" + session","messagePattern":"response publication is at max position: \" \\+ session","errorType":"exception","errorClass":"ArchiveEvent","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/ControlResponseProxy.java","lineNumber":259,"sourceCode":"\n    private static void checkResult(final ControlSession session, final long result)\n    {\n        if (result == Publication.NOT_CONNECTED)\n        {\n            session.abort(ControlSession.RESPONSE_NOT_CONNECTED_MSG);\n            throw new ArchiveEvent(ControlSession.RESPONSE_NOT_CONNECTED_MSG + \": \" + session);\n        }\n\n        if (result == Publication.CLOSED)\n        {\n            session.abort(\"control response publication is closed\");\n            throw new ArchiveEvent(\"response publication is closed: \" + session, AeronException.Category.ERROR);\n        }\n\n        if (result == Publication.MAX_POSITION_EXCEEDED)\n        {\n            session.abort(\"control response publication is at max position\");\n            throw new ArchiveEvent(\n                \"response publication is at max position: \" + session, AeronException.Category.ERROR);\n        }\n    }\n\n    private void logSendResponse(final DirectBuffer buffer, final int offset, final int length)\n    {\n        ArchiveTracing.traceControlResponse(buffer, offset, length);\n    }\n\n    private void logSendSignal(final DirectBuffer buffer, final int offset, final int length)\n    {\n        ArchiveTracing.traceRecordingSignal(buffer, offset, length);\n    }\n}\n","sourceCodeStart":241,"sourceCodeEnd":274,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/ControlResponseProxy.java#L241-L274","documentation":"ControlResponseProxy.checkResult throws ArchiveEvent (Category.ERROR) when the control response publication offer returns Publication.MAX_POSITION_EXCEEDED, meaning the response stream reached the term buffer's maximum position and cannot wrap — the publication cannot progress further. The session is aborted with 'control response publication is at max position'.","triggerScenarios":"sendDescriptor, sendResponse, or send pushing so much data on the control response stream that its position exceeds the publication's max position (term length * 2^31) — effectively an exhausted publication from huge descriptor/response volumes or misconfigured (too small) term buffers on a very long-lived session.","commonSituations":"Very long-lived control sessions sending enormous numbers of responses; sending large recording descriptors in a loop; term-length misconfigured far too small for the response traffic volume.","solutions":["Increase the control response channel term length (term-length URL param on the archive control response channel) so max position is not reachable in practice","Replace long-lived control sessions: clients should disconnect and create a fresh session periodically instead of reusing one indefinitely","Avoid streaming large result sets through the control response channel in unbounded loops; page or batch them","Catch ArchiveEvent and abort/close the session so the client can reconnect with a new session"],"exampleFix":"// before: default tiny term buffers on control response channel\nAeron.Context ctx = new Aeron.Context();\n// archive control-mode response channel without term-length\n// after: configure adequate term length\nString responseChannel = \"aeron:udp?endpoint=localhost:8020|term-length=1m\";\nArchive.Context archiveCtx = new Archive.Context()\n    .controlResponseChannel(responseChannel);","handlingStrategy":"try-catch","validationCode":"long maxPosition = 1L << 62; // generous default; if (publication.position() > maxPosition) recreate session","typeGuard":null,"tryCatchPattern":"try { proxy.sendResponse(...); }\ncatch (ArchiveEvent e)\n{\n    if (e.getMessage().startsWith(\"response publication is at max position\")) { session.abort(e.getMessage()); session.close(); }\n    else { throw e; }\n}","preventionTips":["Configure a large term-length on the control response channel (e.g. 1m or more)","Recycle long-lived control sessions periodically instead of reusing one forever","Avoid unbounded descriptor/response streaming on a single session","Alert on publication position growth on control response streams"],"tags":["java","aeron-archive","publication","max-position","buffer-exhausted"],"backgroundTag":"resource-limit-exceeded","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"}