apache/flink · error · IllegalArgumentException
At least one trigger condition must be configured.
Error message
At least one trigger condition must be configured.
What it means
Thrown by FileCompactStrategy.Builder.validate() when neither setSizeThreshold nor enableCompactionOnCheckpoint has been called before build(). Both default to -1 (disabled), meaning no compaction trigger would ever fire. At least one trigger condition is required for the compaction strategy to be valid.
Source
Thrown at flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/sink/compactor/FileCompactStrategy.java:107
return this;
}
/** Optional, the count of compacting threads in a compactor operator, 1 by default. */
public FileCompactStrategy.Builder setNumCompactThreads(int numCompactThreads) {
checkArgument(numCompactThreads > 0, "Compact threads should be more than 0.");
this.numCompactThreads = numCompactThreads;
return this;
}
public FileCompactStrategy build() {
validate();
return new FileCompactStrategy(
sizeThreshold, numCheckpointsBeforeCompaction, numCompactThreads);
}
private void validate() {
if (sizeThreshold < 0 && numCheckpointsBeforeCompaction <= 0) {
throw new IllegalArgumentException(
"At least one trigger condition must be configured.");
}
}
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Call enableCompactionOnCheckpoint(n) with a positive checkpoint count before build().
- Or call setSizeThreshold(bytes) with a non-negative size threshold before build().
- Both can be set simultaneously for size-and-checkpoint-based triggering.
- Review the FileCompactStrategy.Builder documentation: trigger methods are optional individually but at least one is required.
Example fix
// before: no trigger configured
FileCompactStrategy strategy = FileCompactStrategy.Builder.newBuilder()
.setNumCompactThreads(2)
.build();
// after: configure a trigger condition
FileCompactStrategy strategy = FileCompactStrategy.Builder.newBuilder()
.enableCompactionOnCheckpoint(3)
.setNumCompactThreads(2)
.build(); Defensive patterns
Strategy: validation
Validate before calling
// Always configure at least one trigger before building
FileCompactStrategy strategy = FileCompactStrategy.Builder.newBuilder()
.enableCompactionOnCheckpoint(3) // checkpoint-based trigger
// OR: .setSizeThreshold(128 * 1024 * 1024) // size-based trigger
.setNumCompactThreads(2)
.build(); Try / catch
try {
FileCompactStrategy strategy = FileCompactStrategy.Builder.newBuilder().build();
} catch (IllegalArgumentException e) {
// configure a trigger and retry
strategy = FileCompactStrategy.Builder.newBuilder()
.enableCompactionOnCheckpoint(3)
.build();
} Prevention
- Always chain at least one trigger method (enableCompactionOnCheckpoint or setSizeThreshold) before build().
- Review the builder documentation: both trigger methods are optional individually but at least one is mandatory.
- Use code review to catch missing trigger configuration.
When it happens
Trigger: Calling FileCompactStrategy.Builder.newBuilder().build() without configuring any trigger. Also triggered if only setNumCompactThreads is called, since that configures execution threads but not a trigger condition.
Common situations: Developer forgets to set a trigger condition; copy-paste error from incomplete documentation or examples; misunderstanding that numCompactThreads alone is not a trigger.
Related errors
- The cpu cores should be positive.
- The cpu cores and task heap memory are required when specify
- The jarFile and entryPointClassName can not be null at the s
- Not allowed configuration change(s) were detected:\n - {erro
- Could not create writer state serializer.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/92a12c76e839db66.
Report an issue: GitHub.