aeron-io/aeron · error · IllegalStateException

Log file length less than min length of : length=

Error message

Log file length less than min length of : length=

What it means

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.

Solutions

  1. Delete the truncated log file and let the driver recreate it (clean the aeron directory while no clients are active).
  2. Check for disk-full/crash conditions that caused the truncation and restart the media driver.
  3. Verify no concurrent cleanup/retention process is deleting files under the aeron directory.

Example fix

// before
// driver restarted over a truncated file
LogBuffers buffers = new LogBuffers(logFileName);
// after
File logFile = new File(logFileName);
if (!logFile.exists() || logFile.length() < LogBufferDescriptor.LOG_META_DATA_LENGTH) {
    logFile.delete(); // recreate via driver
}
LogBuffers buffers = new LogBuffers(logFileName);
Defensive patterns

Strategy: try-catch

Validate before calling

File f = new File(logFileName);
if (!f.exists() || f.length() < LogBufferDescriptor.LOG_META_DATA_LENGTH) {
    // treat as corrupt: delete and recreate
}

Try / catch

try {
    return new LogBuffers(logFileName);
} catch (IllegalStateException e) {
    if (e.getMessage().contains("Log file length less than min length")) {
        new File(logFileName).delete();
        return recreateLog();
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of aeron-io/aeron@6d60124e15 (2026-09-12). Data as JSON: /api/errors/b39df338e7d0686c. Report an issue: GitHub.

Appendix: source

Thrown at aeron-client/src/main/java/io/aeron/LogBuffers.java:92

     *
     * @param logFileName to be mapped.
     * @param readOnly flag to indicate if mapping should only be read-only.
     */
    public LogBuffers(final String logFileName, final boolean readOnly)
    {
        int termLength = 0;
        FileChannel fileChannel = null;
        UnsafeBuffer logMetaDataBuffer = null;
        MappedByteBuffer[] mappedByteBuffers = null;

        try
        {
            final EnumSet<StandardOpenOption> fileOptions = readOnly ? FILE_OPTIONS_R : FILE_OPTIONS_RW;
            fileChannel = FileChannel.open(Paths.get(logFileName), fileOptions);
            final long logLength = fileChannel.size();
            if (logLength < LOG_META_DATA_LENGTH)
            {
                throw new IllegalStateException(
                    "Log file length less than min length of " + LOG_META_DATA_LENGTH + ": length=" + logLength);
            }

            final FileChannel.MapMode mapMode = readOnly ? READ_ONLY : READ_WRITE;
            if (logLength < Integer.MAX_VALUE)
            {
                final MappedByteBuffer mappedBuffer = fileChannel.map(mapMode, 0, logLength);
                mappedBuffer.order(ByteOrder.LITTLE_ENDIAN);
                mappedByteBuffers = new MappedByteBuffer[]{ mappedBuffer };

                logMetaDataBuffer = new UnsafeBuffer(
                    mappedBuffer, (int)(logLength - LOG_META_DATA_LENGTH), LOG_META_DATA_LENGTH);

                termLength = LogBufferDescriptor.termLength(logMetaDataBuffer);
                final int pageSize = LogBufferDescriptor.pageSize(logMetaDataBuffer);

                checkTermLength(termLength);
                checkPageSize(pageSize);

View on GitHub (pinned to 6d60124e15)