apache/hadoop · error · IOException
Cannot start trash emptier with negative interval. Set fs.tr
Error message
Cannot start trash emptier with negative interval. Set fs.trash.interval to a positive value.
What it means
NameNode.startTrashEmptier reads fs.trash.interval from the configuration: 0 disables the emptier (method returns), but any negative value throws IOException at startup because a trash-emptier thread cannot be scheduled with a negative interval. The NameNode refuses to start the background emptier with a nonsensical period.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:1066
if (plugins != null) {
for (ServicePlugin p : plugins) {
try {
p.stop();
} catch (Throwable t) {
LOG.warn("ServicePlugin " + p + " could not be stopped", t);
}
}
}
stopHttpServer();
}
private void startTrashEmptier(final Configuration conf) throws IOException {
long trashInterval =
conf.getLong(FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT);
if (trashInterval == 0) {
return;
} else if (trashInterval < 0) {
throw new IOException("Cannot start trash emptier with negative interval."
+ " Set " + FS_TRASH_INTERVAL_KEY + " to a positive value.");
}
// This may be called from the transitionToActive code path, in which
// case the current user is the administrator, not the NN. The trash
// emptier needs to run as the NN. See HDFS-3972.
FileSystem fs = SecurityUtil.doAsLoginUser(
new PrivilegedExceptionAction<FileSystem>() {
@Override
public FileSystem run() throws IOException {
FileSystem dfs = new DistributedFileSystem();
dfs.initialize(FileSystem.getDefaultUri(conf), conf);
return dfs;
}
});
this.emptier = new Thread(new Trash(fs, conf).getEmptier(), "Trash Emptier");
this.emptier.setDaemon(true);
this.emptier.start();View on GitHub (pinned to 2add963021)
Solutions
- Set fs.trash.interval to 0 in core-site.xml to disable the trash emptier, or to a positive value in minutes (e.g., 60, 1440).
- Restart the NameNode after fixing the configuration so startTrashEmptier re-reads it.
- Fix the automation/template that produced the negative value so it can never emit one again.
Example fix
<!-- before: core-site.xml --> <property><name>fs.trash.interval</name><value>-1</value></property> <!-- after --> <property><name>fs.trash.interval</name><value>0</value></property> <!-- 0 disables trash emptier; positive = retention minutes -->
Defensive patterns
Strategy: validation
Validate before calling
// fail fast at deploy time, before the NN hits it at startup
long interval = conf.getLong(FS_TRASH_INTERVAL_KEY, FS_TRASH_INTERVAL_DEFAULT);
Preconditions.checkArgument(interval >= 0,
"fs.trash.interval must be >= 0 (0 disables), got %s", interval); Prevention
- Lint core-site.xml: fs.trash.interval must be 0 or positive minutes; -1 is never valid.
- In configuration templates, clamp computed intervals to >= 0 with a sane default.
- Use 'hdfs getconf -confKey fs.trash.interval' in smoke tests before starting services.
When it happens
Trigger: core-site.xml (or an equivalent config source) sets fs.trash.interval to a negative number and the NameNode starts or transitions to active (startTrashEmptier runs on the active NN; see also HDFS-3972 where it runs as the login user).
Common situations: Operators set -1 trying to 'disable' trash (the correct disable value is 0); configuration management templates that compute the interval and can emit negatives; copy-paste from docs of other systems where -1 means infinite.
Related errors
- Unknown nameservice: {}
- Configuration has multiple addresses that match local node's
- Configuration dfs.namenode.rpc-address must be suffixed with
- Incompatible node types: storageType={storageType} but Stora
- All specified directories are not accessible or do not exist
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/fd2d65ba8fe6dccf.
Report an issue: GitHub.