{"record":{"id":"8bc3589087bc0bb4","repo":"aeron-io/aeron","slug":"segment-file-length-not-in-valid-range-segmentfilelength","errorCode":null,"errorMessage":"segment file length not in valid range: ${segmentFileLength}","messagePattern":"segment file length not in valid range: (.+?)","errorType":"exception","errorClass":"ArchiveException","httpStatus":null,"severity":"error","filePath":"aeron-archive/src/main/java/io/aeron/archive/Archive.java","lineNumber":1486,"sourceCode":"                            archiveId),\n                        ArchiveCounters.allocate(\n                            aeron,\n                            tempBuffer,\n                            AeronCounters.ARCHIVE_CYCLE_TIME_THRESHOLD_EXCEEDED_TYPE_ID,\n                            \"archive-replayer work cycle time exceeded count: threshold=\" +\n                                SystemUtil.formatDuration(replayerCycleThresholdNs) + \" \" + threadingMode.name(),\n                            archiveId),\n                        replayerCycleThresholdNs);\n                }\n            }\n\n            if (!isPowerOfTwo(segmentFileLength))\n            {\n                throw new ArchiveException(\"segment file length not a power of 2: \" + segmentFileLength);\n            }\n            else if (segmentFileLength < TERM_MIN_LENGTH || segmentFileLength > TERM_MAX_LENGTH)\n            {\n                throw new ArchiveException(\"segment file length not in valid range: \" + segmentFileLength);\n            }\n\n            if (null == authenticatorSupplier)\n            {\n                authenticatorSupplier = Configuration.authenticatorSupplier();\n            }\n\n            if (null == authorisationServiceSupplier)\n            {\n                authorisationServiceSupplier = Configuration.authorisationServiceSupplier();\n            }\n\n            concludeRecordChecksum();\n            concludeReplayChecksum();\n\n            if (null == catalog)\n            {\n                catalog = new Catalog(","sourceCodeStart":1468,"sourceCodeEnd":1504,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-archive/src/main/java/io/aeron/archive/Archive.java#L1468-L1504","documentation":"After the power-of-two check, Archive validates segmentFileLength is within TERM_MIN_LENGTH..TERM_MAX_LENGTH (the term buffer bounds). Archive throws ArchiveException if the configured value falls outside that range.","triggerScenarios":"Setting Archive.Context.segmentFileLength(...) to a value smaller than the minimum term length or larger than the maximum (e.g. 64KB or 8GB+), then launching the archive.","commonSituations":"Trying to shrink segments below the Aeron term minimum to save disk, or enlarging beyond the term maximum to reduce segment count.","solutions":["Choose a segmentFileLength between TERM_MIN_LENGTH and TERM_MAX_LENGTH (and a power of two), e.g. 1 << 30.","If smaller segments are needed, lower the term length constraints in the driver configuration instead.","Clamp/validate the value programmatically before configuring Archive.Context."],"exampleFix":"// before\nctx.segmentFileLength(1 << 16); // 64KiB, below TERM_MIN_LENGTH\n// after\nctx.segmentFileLength(1 << 30); // 1GiB, valid power-of-2 in range","handlingStrategy":"validation","validationCode":"if (segmentFileLength < Archive.Configuration.TERM_MIN_LENGTH ||\n    segmentFileLength > Archive.Configuration.TERM_MAX_LENGTH)\n{\n    throw new IllegalArgumentException(\"segmentFileLength out of range: \" + segmentFileLength);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp configured values to TERM_MIN_LENGTH..TERM_MAX_LENGTH","Reuse Archive.Configuration constants rather than hard-coded sizes"],"tags":["aeron","archive","configuration","validation"],"backgroundTag":"value-out-of-range","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"}