apache/cassandra · warning
User defined function %s ran longer than %dms
Error message
User defined function %s ran longer than %dms
What it means
UDFunction.async logs a warning (and warns the client via ClientWarn) when a user-defined function execution exceeds user_defined_function_warn_timeout milliseconds. Execution is NOT aborted: after warning, the call waits the remaining warn-to-fail window before enforcing the fail timeout.
Source
Thrown at src/java/org/apache/cassandra/cql3/functions/UDFunction.java:512
}
private <T> T async(ThreadIdAndCpuTime threadIdAndCpuTime, Callable<T> callable)
{
Future<T> future = executor().submit(callable);
try
{
if (DatabaseDescriptor.getUserDefinedFunctionWarnTimeout() > 0)
try
{
return future.get(DatabaseDescriptor.getUserDefinedFunctionWarnTimeout(), TimeUnit.MILLISECONDS);
}
catch (TimeoutException e)
{
// log and emit a warning that UDF execution took long
String warn = String.format("User defined function %s ran longer than %dms", this, DatabaseDescriptor.getUserDefinedFunctionWarnTimeout());
logger.warn(warn);
ClientWarn.instance.warn(warn);
}
// retry with difference of warn-timeout to fail-timeout
return future.get(DatabaseDescriptor.getUserDefinedFunctionFailTimeout() - DatabaseDescriptor.getUserDefinedFunctionWarnTimeout(), TimeUnit.MILLISECONDS);
}
catch (InterruptedException e)
{
Thread.currentThread().interrupt();
throw new UncheckedInterruptedException(e);
}
catch (ExecutionException e)
{
Throwable c = e.getCause();
if (c instanceof RuntimeException)
throw (RuntimeException) c;
throw new RuntimeException(c);
}View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Optimize or simplify the UDF body
- Raise user_defined_function_warn_timeout in cassandra.yaml if the runtime is expected
- Precompute/filter rows before applying the UDF to reduce invocations
Example fix
# cassandra.yaml # before user_defined_function_warn_timeout: 500 # after user_defined_function_warn_timeout: 5000
Defensive patterns
Strategy: validation
Validate before calling
// Pre-deploy: benchmark the UDF on representative data
long t0 = System.nanoTime(); udf.call(sampleInput); long ms = (System.nanoTime()-t0)/1_000_000;
if (ms > warnTimeout) throw new IllegalStateException("UDF too slow: " + ms + "ms"); Prevention
- Keep UDF bodies trivial (pure, in-memory, constant-time per row)
- Benchmark UDFs against worst-case cell sizes before deploying
- Review user_defined_function_warn_timeout/fail_timeout settings when tuning
When it happens
Trigger: A UDF's future.get() times out at getUserDefinedFunctionWarnTimeout(); invoked via executeAsync or executeAggregateAsync when running a SELECT containing the UDF.
Common situations: UDFs doing expensive per-row computation (regex, crypto, large JSON parsing); JVM pauses; slow sandboxed code on large cells.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- Command '${command}' took too long (${execTime}ms >= ${quota
- Some operations timed out, details available at debug level
- ${executor.name} not terminated
- user_defined_functions_warn_timeout must less than user_defi
- To be able to set enable_user_defined_functions_threads: fal
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/7127df3e40a3be9b.
Report an issue: GitHub.