apache/hadoop · error · IllegalArgumentException

Unexpected not positive size: {}

Error message

Unexpected not positive size: {}

What it means

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.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java:658

  public Set<InetSocketAddress> getAuxiliaryRpcAddresses() {
    return clientRpcServer.getAuxiliaryListenerAddresses();
  }

  private static UserGroupInformation getRemoteUser() throws IOException {
    return NameNode.getRemoteUser();
  }


  /////////////////////////////////////////////////////
  // NamenodeProtocol
  /////////////////////////////////////////////////////
  @Override // NamenodeProtocol
  public BlocksWithLocations getBlocks(DatanodeInfo datanode, long size, long
      minBlockSize, long timeInterval, StorageType storageType)
      throws IOException {
    String operationName = "getBlocks";
    if(size <= 0) {
      throw new IllegalArgumentException(
          "Unexpected not positive size: "+size);
    }
    if(minBlockSize < 0) {
      throw new IllegalArgumentException(
          "Unexpected not positive size: "+size);
    }
    checkNNStartup();
    namesystem.checkSuperuserPrivilege(operationName);
    namesystem.checkNameNodeSafeMode("Cannot execute getBlocks");
    return namesystem.getBlocks(datanode, size, minBlockSize, timeInterval, storageType);
  }

  @Override // NamenodeProtocol
  public ExportedBlockKeys getBlockKeys() throws IOException {
    String operationName = "getBlockKeys";
    checkNNStartup();
    namesystem.checkSuperuserPrivilege(operationName);
    return namesystem.getBlockManager().getBlockKeys();

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass a positive byte budget, e.g. 2147483648 (2GB) exactly like the stock Balancer
  2. In custom clients, validate size > 0 before the RPC call
  3. If running a patched balancer, upgrade it to the stock version matching the cluster's Hadoop
  4. Check the caller for swapped arguments - size and minBlockSize are adjacent longs

Example fix

// before
BlocksWithLocations blocks = proxy.getBlocks(dn, 0, 0, 0, null);

// after - positive size budget (2GB, as the stock Balancer uses)
BlocksWithLocations blocks = proxy.getBlocks(dn, 2L * 1024 * 1024 * 1024, 0, 0, null);
Defensive patterns

Strategy: validation

Validate before calling

long size = 2L * 1024 * 1024 * 1024; // byte budget, must be > 0
if (size <= 0) throw new IllegalArgumentException("getBlocks size must be > 0, got " + size);
BlocksWithLocations b = proxy.getBlocks(dn, size, minBlockSize, interval, type);

Type guard

static boolean isValidGetBlocksSize(long size) {
  return size > 0;
}

Try / catch

catch (IllegalArgumentException e) {
  if (e.getMessage().contains("Unexpected not positive size")) {
    // fix the caller's size budget (default it to 2GB) and retry
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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