apache/cassandra · error · ParseException

Commit log position must be given as <segment>,<position>

Error message

Commit log position must be given as <segment>,<position>

What it means

CommitLogPosition's Format.fromString parses a human-readable commit log position string. An empty/null string maps to NONE, but any non-empty string that does not split into exactly two comma-separated parts (segment id, position) raises a java.text.ParseParseException 'Commit log position must be given as <segment>,<position>'.

Source

Thrown at src/java/org/apache/cassandra/db/commitlog/CommitLogPosition.java:131

        }

        public CommitLogPosition deserialize(DataInputPlus in) throws IOException
        {
            return new CommitLogPosition(in.readLong(), in.readInt());
        }

        public long serializedSize(CommitLogPosition clsp)
        {
            return TypeSizes.sizeof(clsp.segmentId) + TypeSizes.sizeof(clsp.position);
        }

        public CommitLogPosition fromString(String position) throws ParseException
        {
            if (Strings.isNullOrEmpty(position))
                return NONE;
            String[] parts = position.split(",");
            if (parts.length != 2)
                throw new ParseException("Commit log position must be given as <segment>,<position>", 0);
            return new CommitLogPosition(Long.parseLong(parts[0].trim()), Integer.parseInt(parts[1].trim()));
        }

        public String toString(CommitLogPosition position)
        {
            return position == NONE ? "" : String.format("%d, %d", position.segmentId, position.position);
        }
    }
}

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Supply the value as '<segmentId>,<position>' with exactly one comma, e.g. '1690000000000,12345'.
  2. Trim surrounding whitespace — parsing already trims inner parts, but the split still requires the comma delimiter.
  3. Pass an empty string intentionally (maps to NONE) if no position bound is desired.
  4. Validate input with a regex like '^\d+,\d+$' before handing it to fromString.

Example fix

// before
CommitLogPosition.fromString("1690000000000 12345"); // ParseException
// after
CommitLogPosition.fromString("1690000000000,12345");
Defensive patterns

Strategy: validation

Validate before calling

if (position != null && !position.isBlank() && !position.matches("^\\s*\\d+\\s*,\\s*\\d+\\s*$"))
    throw new IllegalArgumentException("Position must be '<segment>,<position>'");

Try / catch

try { pos = CommitLogPosition.fromString(raw); } catch (ParseException e) { logger.error("Bad position '{}': use <segment>,<position>", raw); }

Prevention

When it happens

Trigger: Calling CommitLogPosition.fromString with a value missing the comma or containing extra segments, e.g. configuration values for restore positions or tool arguments like '12345' or '1,2,3' instead of '12345,678'.

Common situations: Typo when setting a commit log restore position in configuration files, scripting that forgets the comma, or pasting a position that includes whitespace-separated instead of comma-separated values.

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/763b8bf6d464af4e. Report an issue: GitHub.