{"record":{"id":"b39df338e7d0686c","repo":"aeron-io/aeron","slug":"log-file-length-less-than-min-length-of-length","errorCode":null,"errorMessage":"Log file length less than min length of : length=","messagePattern":"Log file length less than min length of : length=","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"aeron-client/src/main/java/io/aeron/LogBuffers.java","lineNumber":92,"sourceCode":"     *\n     * @param logFileName to be mapped.\n     * @param readOnly flag to indicate if mapping should only be read-only.\n     */\n    public LogBuffers(final String logFileName, final boolean readOnly)\n    {\n        int termLength = 0;\n        FileChannel fileChannel = null;\n        UnsafeBuffer logMetaDataBuffer = null;\n        MappedByteBuffer[] mappedByteBuffers = null;\n\n        try\n        {\n            final EnumSet<StandardOpenOption> fileOptions = readOnly ? FILE_OPTIONS_R : FILE_OPTIONS_RW;\n            fileChannel = FileChannel.open(Paths.get(logFileName), fileOptions);\n            final long logLength = fileChannel.size();\n            if (logLength < LOG_META_DATA_LENGTH)\n            {\n                throw new IllegalStateException(\n                    \"Log file length less than min length of \" + LOG_META_DATA_LENGTH + \": length=\" + logLength);\n            }\n\n            final FileChannel.MapMode mapMode = readOnly ? READ_ONLY : READ_WRITE;\n            if (logLength < Integer.MAX_VALUE)\n            {\n                final MappedByteBuffer mappedBuffer = fileChannel.map(mapMode, 0, logLength);\n                mappedBuffer.order(ByteOrder.LITTLE_ENDIAN);\n                mappedByteBuffers = new MappedByteBuffer[]{ mappedBuffer };\n\n                logMetaDataBuffer = new UnsafeBuffer(\n                    mappedBuffer, (int)(logLength - LOG_META_DATA_LENGTH), LOG_META_DATA_LENGTH);\n\n                termLength = LogBufferDescriptor.termLength(logMetaDataBuffer);\n                final int pageSize = LogBufferDescriptor.pageSize(logMetaDataBuffer);\n\n                checkTermLength(termLength);\n                checkPageSize(pageSize);","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-client/src/main/java/io/aeron/LogBuffers.java#L74-L110","documentation":"LogBuffers' constructor throws this IllegalStateException when the log file on disk is shorter than LOG_META_DATA_LENGTH, the minimum size needed to hold the log metadata buffer. Such a file is truncated or corrupt and cannot be mapped as a valid Aeron log.","triggerScenarios":"Opening an existing log file (via a replay/termination or driver restart) whose fileChannel.size() is below the metadata section size — typically a zero-length or partially written file left by a crashed driver or prematurely deleted/truncated by cleanup.","commonSituations":"Disk-full conditions producing truncated log files; killing the media driver mid-write; external cleanup scripts removing or shrinking files in the aeron directory while a client still references them; wrong file name resolved (empty file created by open).","solutions":["Delete the truncated log file and let the driver recreate it (clean the aeron directory while no clients are active).","Check for disk-full/crash conditions that caused the truncation and restart the media driver.","Verify no concurrent cleanup/retention process is deleting files under the aeron directory."],"exampleFix":"// before\n// driver restarted over a truncated file\nLogBuffers buffers = new LogBuffers(logFileName);\n// after\nFile logFile = new File(logFileName);\nif (!logFile.exists() || logFile.length() < LogBufferDescriptor.LOG_META_DATA_LENGTH) {\n    logFile.delete(); // recreate via driver\n}\nLogBuffers buffers = new LogBuffers(logFileName);","handlingStrategy":"try-catch","validationCode":"File f = new File(logFileName);\nif (!f.exists() || f.length() < LogBufferDescriptor.LOG_META_DATA_LENGTH) {\n    // treat as corrupt: delete and recreate\n}","typeGuard":null,"tryCatchPattern":"try {\n    return new LogBuffers(logFileName);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"Log file length less than min length\")) {\n        new File(logFileName).delete();\n        return recreateLog();\n    }\n    throw e;\n}","preventionTips":["Ensure the media driver shuts down gracefully so logs are fully written.","Monitor disk space to avoid truncated writes.","Exclude the aeron directory from external cleanup/retention jobs while in use."],"tags":["aeron","logbuffers","corruption","file-size"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}