apache/hadoop · error · IOException

Invalid gridmix.sleep.interval: {}

Error message

Invalid gridmix.sleep.interval: {}

What it means

SleepJob's record reader (createRecordReader) reads gridmix.sleep.interval (seconds, default 5), converts it to milliseconds via TimeUnit.MILLISECONDS.convert(value, TimeUnit.SECONDS), and throws IOException if the result is <= 0. The message reports the converted millisecond value, not the configured value, so 'Invalid gridmix.sleep.interval: 0' means the ms-converted setting was 0 or negative.

Source

Thrown at hadoop-tools/hadoop-gridmix/src/main/java/org/apache/hadoop/mapred/gridmix/SleepJob.java:227

  public static class SleepInputFormat
  extends InputFormat<LongWritable, LongWritable> {

    @Override
    public List<InputSplit> getSplits(JobContext jobCtxt) throws IOException {
      return pullDescription(jobCtxt);
    }

    @Override
    public RecordReader<LongWritable, LongWritable> createRecordReader(
      InputSplit split, final TaskAttemptContext context)
      throws IOException, InterruptedException {
      final long duration = split.getLength();
      long sleepInterval = 
    	  context.getConfiguration().getLong(GRIDMIX_SLEEP_INTERVAL, 5);
      final long RINTERVAL = 
        TimeUnit.MILLISECONDS.convert(sleepInterval, TimeUnit.SECONDS);
      if (RINTERVAL <= 0) {
        throw new IOException(
          "Invalid " + GRIDMIX_SLEEP_INTERVAL + ": " + RINTERVAL);
      }
      return new RecordReader<LongWritable, LongWritable>() {
        long start = -1;
        long slept = 0L;
        long sleep = 0L;
        final LongWritable key = new LongWritable();
        final LongWritable val = new LongWritable();

        @Override
        public boolean nextKeyValue() throws IOException {
          if (start == -1) {
            start = System.currentTimeMillis();
          }
          slept += sleep;
          sleep = Math.min(duration - slept, RINTERVAL);
          key.set(slept + sleep + start);
          val.set(duration - slept);

View on GitHub (pinned to 2add963021)

Solutions

  1. Set a positive value in seconds, e.g. -Dgridmix.sleep.interval=5 (the default)
  2. To make sleeps as coarse as possible, set the interval >= the longest expected task duration rather than 0
  3. Check the message's number: it is milliseconds, so divide by 1000 to see what the seconds config resolved to

Example fix

# before
hadoop jar gridmix.jar org.apache.hadoop.mapred.gridmix.Gridmix -Dgridmix.sleep.interval=0 -g trace.json

# after
hadoop jar gridmix.jar org.apache.hadoop.mapred.gridmix.Gridmix -Dgridmix.sleep.interval=5 -g trace.json
Defensive patterns

Strategy: validation

Validate before calling

long interval = conf.getLong("gridmix.sleep.interval", 5);
if (TimeUnit.MILLISECONDS.convert(interval, TimeUnit.SECONDS) <= 0) {
  throw new IllegalArgumentException("gridmix.sleep.interval must be > 0 seconds");
}

Prevention

When it happens

Trigger: Launching gridmix SleepJob with -Dgridmix.sleep.interval=0 or a negative number; sleep jobs are chopped into interval-sized naps, so a non-positive interval breaks the sleep loop and fails fast in the mapper's record reader.

Common situations: Trying to disable sleep fragmentation by setting the interval to 0; typos or math in scripts computing the interval; copying a config where the property name got the wrong unit assumed (it is in SECONDS).

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/eccf243ee0eeaeb8. Report an issue: GitHub.