apache/cassandra · error · RuntimeException

Cannot parse the version of the file:

Error message

Cannot parse the version of the file: 

What it means

CommitLogDescriptor.extactFromFileName matches a segment file name against COMMIT_LOG_FILE_PATTERN. If the name does not match the expected 'CommitLog<version>-<id>.log' pattern, the descriptor cannot be derived from the file name, and a RuntimeException 'Cannot parse the version of the file: <name>' is thrown.

Source

Thrown at src/java/org/apache/cassandra/db/commitlog/CommitLogDescriptor.java:211

    public static CommitLogDescriptor fromFileName(String name)
    {
        Matcher matcher = extactFromFileName(name);
        long id = Long.parseLong(matcher.group(3).split(SEPARATOR)[1]);
        return new CommitLogDescriptor(Integer.parseInt(matcher.group(2)), id, null, new EncryptionContext());
    }

    public static long idFromFileName(String name)
    {
        Matcher matcher = extactFromFileName(name);
        return Long.parseLong(matcher.group(3).split(SEPARATOR)[1]);
    }

    private static Matcher extactFromFileName(String name)
    {
        Matcher matcher = COMMIT_LOG_FILE_PATTERN.matcher(name);
        if (!matcher.matches())
            throw new RuntimeException("Cannot parse the version of the file: " + name);

        if (matcher.group(3) == null)
            throw new UnsupportedOperationException("Commitlog segment is too old to open; upgrade to 1.2.5+ first");

        return matcher;
    }

    public int getMessagingVersion()
    {
        switch (version)
        {
            case VERSION_30:
                return MessagingService.VERSION_30;
            case VERSION_40:
                return MessagingService.VERSION_40;
            case VERSION_50:
                return MessagingService.VERSION_50;
            case VERSION_60:

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Rename the file to the canonical pattern CommitLog<version>-<id>.log (e.g. CommitLog-6-1700000000000.log) if it is a genuine segment.
  2. Remove non-commitlog files (backups, temp copies, editor artifacts) from the commitlog/restore directory.
  3. Verify the restoreDirectories/commitlog location in configuration points only at valid Cassandra commit log segments.
  4. Re-copy the segment from a healthy backup if the name was truncated during transfer.

Example fix

// before
mv CommitLog.log /var/lib/cassandra/commitlog/   // unparseable -> RuntimeException
// after
mv CommitLog.log /var/lib/cassandra/commitlog/CommitLog-6-1690000000000.log
Defensive patterns

Strategy: validation

Validate before calling

Pattern P = Pattern.compile("CommitLog(\\d+)-(\\d+)(\\d*)\\.log");
if (!P.matcher(file.getName()).matches())
    logger.warn("{} is not a valid commit log file name", file.getName());

Try / catch

try { CommitLogDescriptor.fromFileName(name); } catch (RuntimeException e) { logger.error("Bad segment name: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Calling CommitLogDescriptor.fromFileName (or code paths that derive descriptors from names, including archive restore) with a file name that does not match the commit log naming pattern — wrong prefix, missing separator, extra suffixes.

Common situations: Renamed or hand-edited commit log files, restore directory containing non-commitlog files, truncated names from failed copies, or files like 'CommitLog-4-123.log' produced by different tooling/older layouts.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/ea4913fb0174c70c. Report an issue: GitHub.