{"record":{"id":"7ee2cdcd4e5832fb","repo":"apache/hadoop","slug":"unexpected-not-positive-size","errorCode":null,"errorMessage":"Unexpected not positive size: {}","messagePattern":"Unexpected not positive size: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java","lineNumber":658,"sourceCode":"  public Set<InetSocketAddress> getAuxiliaryRpcAddresses() {\n    return clientRpcServer.getAuxiliaryListenerAddresses();\n  }\n\n  private static UserGroupInformation getRemoteUser() throws IOException {\n    return NameNode.getRemoteUser();\n  }\n\n\n  /////////////////////////////////////////////////////\n  // NamenodeProtocol\n  /////////////////////////////////////////////////////\n  @Override // NamenodeProtocol\n  public BlocksWithLocations getBlocks(DatanodeInfo datanode, long size, long\n      minBlockSize, long timeInterval, StorageType storageType)\n      throws IOException {\n    String operationName = \"getBlocks\";\n    if(size <= 0) {\n      throw new IllegalArgumentException(\n          \"Unexpected not positive size: \"+size);\n    }\n    if(minBlockSize < 0) {\n      throw new IllegalArgumentException(\n          \"Unexpected not positive size: \"+size);\n    }\n    checkNNStartup();\n    namesystem.checkSuperuserPrivilege(operationName);\n    namesystem.checkNameNodeSafeMode(\"Cannot execute getBlocks\");\n    return namesystem.getBlocks(datanode, size, minBlockSize, timeInterval, storageType);\n  }\n\n  @Override // NamenodeProtocol\n  public ExportedBlockKeys getBlockKeys() throws IOException {\n    String operationName = \"getBlockKeys\";\n    checkNNStartup();\n    namesystem.checkSuperuserPrivilege(operationName);\n    return namesystem.getBlockManager().getBlockKeys();","sourceCodeStart":640,"sourceCodeEnd":676,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java#L640-L676","documentation":"NamenodeProtocol.getBlocks - the RPC the Balancer uses to pull a datanode's block list - validates arguments first: size (the maximum cumulative bytes of blocks to return) must be > 0, otherwise IllegalArgumentException('Unexpected not positive size: <size>'). The check runs before checkNNStartup/superuser/safemode checks, so this is pure caller-argument validation, not a cluster-state error.","triggerScenarios":"A Balancer or custom NamenodeProtocol client calling getBlocks(datanode, size<=0, ...). The stock Balancer always passes a positive budget (2GB), so size<=0 implies a patched balancer, a custom tool, or a wrapper with swapped/defaulted arguments.","commonSituations":"In-house balancing or block-movement tooling built on NamenodeProtocol protobuf RPC passing 0 as a placeholder; argument-order confusion between size and minBlockSize; code paths where the configured block budget defaults to 0.","solutions":["Pass a positive byte budget, e.g. 2147483648 (2GB) exactly like the stock Balancer","In custom clients, validate size > 0 before the RPC call","If running a patched balancer, upgrade it to the stock version matching the cluster's Hadoop","Check the caller for swapped arguments - size and minBlockSize are adjacent longs"],"exampleFix":"// before\nBlocksWithLocations blocks = proxy.getBlocks(dn, 0, 0, 0, null);\n\n// after - positive size budget (2GB, as the stock Balancer uses)\nBlocksWithLocations blocks = proxy.getBlocks(dn, 2L * 1024 * 1024 * 1024, 0, 0, null);","handlingStrategy":"validation","validationCode":"long size = 2L * 1024 * 1024 * 1024; // byte budget, must be > 0\nif (size <= 0) throw new IllegalArgumentException(\"getBlocks size must be > 0, got \" + size);\nBlocksWithLocations b = proxy.getBlocks(dn, size, minBlockSize, interval, type);","typeGuard":"static boolean isValidGetBlocksSize(long size) {\n  return size > 0;\n}","tryCatchPattern":"catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"Unexpected not positive size\")) {\n    // fix the caller's size budget (default it to 2GB) and retry\n  }\n}","preventionTips":["Default the block budget to the stock Balancer's 2GB in custom tooling","Validate all getBlocks arguments before the RPC - the NN validates size/minBlockSize first","Add unit tests for argument handling in any NamenodeProtocol client wrapper"],"tags":["hdfs","name-node","rpc","balancer","getblocks","argument-validation"],"backgroundTag":"rpc-argument-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}