{"record":{"id":"97f5dad8e3bb2268","repo":"apache/hadoop","slug":"key-v-0","errorCode":null,"errorMessage":"{key} = {v} <= 0","messagePattern":"(.+?) = (.+?) <= 0","errorType":"validation","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java","lineNumber":276,"sourceCode":"  /* Check that this Balancer is compatible with the Block Placement Policy\n   * used by the Namenode.\n   */\n  private static void checkReplicationPolicyCompatibility(Configuration conf\n      ) throws UnsupportedActionException {\n    BlockPlacementPolicies placementPolicies =\n        new BlockPlacementPolicies(conf, null, NetworkTopology.getInstance(conf), null);\n    if (!(placementPolicies.getPolicy(CONTIGUOUS) instanceof\n        BlockPlacementPolicyDefault)) {\n      throw new UnsupportedActionException(\n          \"Balancer without BlockPlacementPolicyDefault\");\n    }\n  }\n\n  static long getLong(Configuration conf, String key, long defaultValue) {\n    final long v = conf.getLong(key, defaultValue);\n    LOG.info(key + \" = \" + v + \" (default=\" + defaultValue + \")\");\n    if (v <= 0) {\n      throw new HadoopIllegalArgumentException(key + \" = \" + v  + \" <= \" + 0);\n    }\n    return v;\n  }\n\n  static long getLongBytes(Configuration conf, String key, long defaultValue) {\n    final long v = conf.getLongBytes(key, defaultValue);\n    LOG.info(key + \" = \" + v + \" (default=\" + defaultValue + \")\");\n    if (v <= 0) {\n      throw new HadoopIllegalArgumentException(key + \" = \" + v  + \" <= \" + 0);\n    }\n    return v;\n  }\n\n  static int getInt(Configuration conf, String key, int defaultValue) {\n    final int v = conf.getInt(key, defaultValue);\n    LOG.info(key + \" = \" + v + \" (default=\" + defaultValue + \")\");\n    if (v <= 0) {\n      throw new HadoopIllegalArgumentException(key + \" = \" + v  + \" <= \" + 0);","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/Balancer.java#L258-L294","documentation":"Balancer.getLong reads a long-typed balancer configuration key, logs its effective value, and throws HadoopIllegalArgumentException when the value is zero or negative. The balancer enforces positivity for its tuning knobs (timeouts, sizes, limits) because a non-positive value would make the run meaningless. The exception message names the exact key and offending value.","triggerScenarios":"Any long-typed balancer knob resolved through Balancer.getLong with value <= 0 in the effective configuration, e.g. setting dfs.datanode.balance.bandwidthPerSec=0 or dfs.balancer.max-size-to-move=0 to try to 'disable' a limit - the helper rejects 0 as well as negatives.","commonSituations":"Operators trying to disable bandwidth throttling or size caps by setting them to 0; typos like a stray '-' sign; units confusion where 0 is legal for a different key but not for the ones routed through this helper.","solutions":["Find the key named in the exception message and set it to a positive value in hdfs-site.xml (or pass -Dkey=value via HADOOP_OPTS)","If you meant 'unlimited', use a very large positive value (e.g. 1t for size keys) rather than 0","Re-run the balancer and confirm the startup log line 'key = value (default=...)' shows your intended value"],"exampleFix":"// before\n<property><name>dfs.balancer.max-size-to-move</name><value>0</value></property>\n\n// after\n<property><name>dfs.balancer.max-size-to-move</name><value>10737418240</value></property>","handlingStrategy":"validation","validationCode":"static void requirePositiveLong(Configuration conf, String key, long def) {\n  long v = conf.getLong(key, def);\n  if (v <= 0) throw new HadoopIllegalArgumentException(key + \" = \" + v + \" <= 0\");\n}\n// run for every long knob you set before invoking the balancer","typeGuard":null,"tryCatchPattern":"catch (HadoopIllegalArgumentException e) { log.error(\"Balancer config rejected: {}\", e.getMessage()); fixConfigAndRetry(); }","preventionTips":["Never use 0 to mean 'disabled' for balancer size/time knobs - use a large value instead","Lint cluster configs for known keys with non-positive numeric values before deploying","Watch the balancer's startup 'key = value (default=...)' log lines to confirm effective values"],"tags":["hdfs","balancer","configuration","validation"],"backgroundTag":"invalid-configuration-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}