apache/cassandra · error · RuntimeException
Unable to parse precision of value
Error message
Unable to parse precision of value
What it means
Thrown when the 'precision' property in commitlog_archiving.properties is not a valid java.util.concurrent.TimeUnit name. Cassandra parses it with TimeUnit.valueOf(), which only accepts HOURS, MINUTES, SECONDS, MILLISECONDS, MICROSECONDS (NANOSECONDS rejected separately). The IllegalArgumentException is chained.
Source
Thrown at src/java/org/apache/cassandra/db/commitlog/CommitLogArchiver.java:154
if (!directory.exists())
{
if (!directory.tryCreateDirectory())
{
throw new RuntimeException("Unable to create directory: " + dir);
}
}
}
}
String precisionPropertyValue = commitlogCommands.getProperty("precision", TimeUnit.MICROSECONDS.name());
TimeUnit precision;
try
{
precision = TimeUnit.valueOf(precisionPropertyValue);
}
catch (IllegalArgumentException ex)
{
throw new RuntimeException("Unable to parse precision of value " + precisionPropertyValue, ex);
}
if (precision == TimeUnit.NANOSECONDS)
throw new RuntimeException("NANOSECONDS level precision is not supported.");
String targetTime = commitlogCommands.getProperty("restore_point_in_time");
long restorePointInTime = Long.MAX_VALUE;
try
{
if (!Strings.isNullOrEmpty(targetTime))
{
// get restorePointInTime in microseconds level by default as cassandra use this level's timestamp
restorePointInTime = getRestorationPointInTimeInMicroseconds(targetTime);
}
}
catch (DateTimeParseException e)
{
throw new RuntimeException("Unable to parse restore target time", e);
}View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Set precision to an exact uppercase TimeUnit constant, e.g. MICROSECONDS (the default).
- Remove the precision line entirely to accept the default (MICROSECONDS).
- Use HOURS, MINUTES, SECONDS, MILLISECONDS, or MICROSECONDS only — NANOSECONDS is explicitly unsupported.
Example fix
# before precision: microseconds # after precision: MICROSECONDS
Defensive patterns
Strategy: validation
Validate before calling
String p = props.getProperty("precision");
Set<String> allowed = Set.of("HOURS","MINUTES","SECONDS","MILLISECONDS","MICROSECONDS");
if (p != null && !allowed.contains(p.trim().toUpperCase()))
throw new IllegalArgumentException("precision must be one of " + allowed); Try / catch
try { archiver = CommitLogArchiver.construct(); }
catch (RuntimeException e) {
if (e.getMessage().startsWith("Unable to parse precision"))
log.error("precision must be an uppercase TimeUnit constant", e);
throw e;
} Prevention
- Use only uppercase TimeUnit constant names in commitlog_archiving.properties
- Add config linting to CI that validates precision values
- Omit precision to accept the MICROSECONDS default
When it happens
Trigger: getArchiverFromProperties() reads property 'precision' with a value like 'microseconds', 'us', or 'Microseconds' and TimeUnit.valueOf() throws IllegalArgumentException.
Common situations: Lowercase or abbreviated time units in the properties file; copy-pasted values like 'micro' or 'µs'; confusion between the property name and accepted enum constants.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- commitlog_directory must not be the same as any data_file_di
- local_system_data_file_directory must not be the same as the
- Unknown commitlog service type: <commitLogSync>
- Unable to load commitlog_archiving.properties
- Unable to create directory:
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/39723fe2edbc195d.
Report an issue: GitHub.