apache/cassandra · error · IllegalArgumentException
Max profiling duration is %s seconds. If you need longer pro
Error message
Max profiling duration is %s seconds. If you need longer profiling, use execute command instead.
What it means
parseDuration converts a duration string (via DurationSpec.IntSecondsBound) into seconds for the profiler, but caps it at MAX_SAFE_PROFILING_DURATION because very long in-process profiling sessions risk unbounded output files and memory pressure. Longer runs must use the raw execute() command path instead.
Source
Thrown at src/java/org/apache/cassandra/service/AsyncProfilerService.java:418
}
public static String validateCommand(String command)
{
if (command == null || command.isBlank())
throw new IllegalArgumentException("Command can not be null or blank string.");
return command;
}
/**
* @param duration duration of profiling
* @return converted string representation of duration to seconds
*/
public static int parseDuration(String duration)
{
int durationSeconds = new DurationSpec.IntSecondsBound(duration).toSeconds();
if (durationSeconds > MAX_SAFE_PROFILING_DURATION)
throw new IllegalArgumentException(format("Max profiling duration is %s seconds. If you need longer profiling, use execute command instead.",
MAX_SAFE_PROFILING_DURATION));
return durationSeconds;
}
private static void maybeCreateProfilesLogDir()
{
String dir = new File(logDir).toAbsolute().toString();
if ((DatabaseDescriptor.getCommitLogLocation() != null && dir.startsWith(DatabaseDescriptor.getCommitLogLocation())) ||
(DatabaseDescriptor.getAccordJournalDirectory() != null && dir.startsWith(DatabaseDescriptor.getAccordJournalDirectory())) ||
dir.startsWith(DatabaseDescriptor.getHintsDirectory().absolutePath()) ||
(DatabaseDescriptor.getCDCLogLocation() != null && dir.startsWith(DatabaseDescriptor.getCDCLogLocation())) ||
(DatabaseDescriptor.getSavedCachesLocation() != null && dir.startsWith(DatabaseDescriptor.getSavedCachesLocation())))
{
throw new RuntimeException("You can not store Async-Profiler results into system Cassandra directory.");
}
for (String location : StorageService.instance.getAllDataFileLocations())View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Reduce the requested duration to at most MAX_SAFE_PROFILING_DURATION seconds (as printed in the message)
- For longer profiling, enable unsafe mode and use the execute() MBean operation with async-profiler's own arguments
- Use start/stop style commands to bracket a long interval instead of a single timed run
Example fix
// before
service.cmd("start,profile,output.html", "30d");
// after
service.cmd("start,profile,output.html", "300s"); // or use execute() for longer runs Defensive patterns
Strategy: validation
Validate before calling
int secs = (int)(Duration.parse(dur).toSeconds());
if (secs > AsyncProfilerService.MAX_SAFE_PROFILING_DURATION) throw new IllegalArgumentException("duration too long; use execute()"); Try / catch
try { svc.cmd(command, duration); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Max profiling duration")) { svc.cmd(command, "300s"); } else throw e; } Prevention
- Keep timed profiles under MAX_SAFE_PROFILING_DURATION seconds
- Use start/stop bracketing or execute() for long-running profiling
- Parse durations with DurationSpec in tooling to match server semantics
When it happens
Trigger: Calling cmd()/apply() with duration='24h' (or any duration exceeding MAX_SAFE_PROFILING_DURATION seconds) so the parsed seconds exceed the cap.
Common situations: Operators trying to profile an entire day; scripts converting 'infinity' or large values; confusion between the safe start/stop workflow and execute()-based long profiling.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Invalid value of auto_snapshot_ttl: ${conf.auto_snapshot_ttl
- Invalid duration: %s Accepted units:%s where case matters an
- Invalid duration: value must be non-negative
- Unsupported time unit: %s. Supported units are: %s
- The duration months, days and nanoseconds must be all of the
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/58b32340cca830bb.
Report an issue: GitHub.