{"record":{"id":"f8f98bc5fa683e05","repo":"apache/hadoop","slug":"unrecognized-flush-interval-rollinterval-must","errorCode":null,"errorMessage":"Unrecognized flush interval: ${rollInterval}. Must be a number followed by an optional unit. The unit must be one of: minute, hour, day","messagePattern":"Unrecognized flush interval: (.+?)\\. Must be a number followed by an optional unit\\. The unit must be one of: minute, hour, day","errorType":"exception","errorClass":"MetricsException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/RollingFileSystemSink.java","lineNumber":356,"sourceCode":"   *\n   * @return the roll interval in millis\n   */\n  @VisibleForTesting\n  protected long getRollInterval() {\n    String rollInterval =\n        properties.getString(ROLL_INTERVAL_KEY, DEFAULT_ROLL_INTERVAL);\n    Pattern pattern = Pattern.compile(\"^\\\\s*(\\\\d+)\\\\s*([A-Za-z]*)\\\\s*$\");\n    Matcher match = pattern.matcher(rollInterval);\n    long millis;\n\n    if (match.matches()) {\n      String flushUnit = match.group(2);\n      int rollIntervalInt;\n\n      try {\n        rollIntervalInt = Integer.parseInt(match.group(1));\n      } catch (NumberFormatException ex) {\n        throw new MetricsException(\"Unrecognized flush interval: \"\n            + rollInterval + \". Must be a number followed by an optional \"\n            + \"unit. The unit must be one of: minute, hour, day\", ex);\n      }\n\n      if (\"\".equals(flushUnit)) {\n        millis = TimeUnit.HOURS.toMillis(rollIntervalInt);\n      } else {\n        switch (flushUnit.toLowerCase()) {\n        case \"m\":\n        case \"min\":\n        case \"minute\":\n        case \"minutes\":\n          millis = TimeUnit.MINUTES.toMillis(rollIntervalInt);\n          break;\n        case \"h\":\n        case \"hr\":\n        case \"hour\":\n        case \"hours\":","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/RollingFileSystemSink.java#L338-L374","documentation":"The roll-interval property is matched against ^\\s*(\\d+)\\s*([A-Za-z]*)\\s*$ and the digit group is parsed with Integer.parseInt. Because the regex already guarantees the first group is all digits, the NumberFormatException branch fires only when the number exceeds Integer.MAX_VALUE (2147483647). The misleading 'Unrecognized flush interval' message then blames the whole value even though the number was simply too large for a 32-bit int.","triggerScenarios":"roll-interval with a numeric part above 2147483647, e.g. roll-interval=2592000000 (someone computing 30 days in milliseconds) or roll-interval=99999999999hours.","commonSituations":"Copy-pasting millisecond durations from other tools' configs (where roll intervals are expressed in millis); scripts that generate the interval arithmetically and overflow int range.","solutions":["Use a small number plus an explicit unit: roll-interval=30days or roll-interval=720h","Remember a bare number means HOURS and must fit in a 32-bit int (max ~245,000 years — never a real constraint)","Never express this property in milliseconds; the minimum unit is minutes"],"exampleFix":"# before\n*.sink.rolling.roll-interval=2592000000  # 30 days in millis -> parseInt overflow\n\n# after\n*.sink.rolling.roll-interval=30days","handlingStrategy":"validation","validationCode":"Matcher m = Pattern.compile(\"^\\\\s*(\\\\d+)\\\\s*([A-Za-z]*)\\\\s*$\").matcher(rollInterval);\nif (!m.matches() || Long.parseLong(m.group(1)) > Integer.MAX_VALUE) {\n  throw new IllegalArgumentException(\"roll-interval number exceeds int range: \"\n      + rollInterval + \" — use a small number plus minute/hour/day unit\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  sink.init(subsetConf);\n} catch (MetricsException e) {\n  // 'Unrecognized flush interval' wrapping NumberFormatException => numeric part > Integer.MAX_VALUE\n  LOG.error(\"Invalid roll-interval '{}': number must fit in a 32-bit int\", rollInterval, e);\n}","preventionTips":["Never express roll-interval in milliseconds; always use number+unit (30days, 12hours)","Keep the numeric part small — bare numbers are interpreted as hours","Lint generated hadoop-metrics2.properties for absurdly large integers"],"tags":["metrics2","rolling-file-sink","configuration","numberformat-exception","integer-overflow"],"backgroundTag":"numberformat-exception","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}