{"record":{"id":"5e565934517ee9c8","repo":"apache/hadoop","slug":"number-of-thresholds-should-be-was","errorCode":null,"errorMessage":"Number of thresholds should be {}. Was: {}","messagePattern":"Number of thresholds should be (.+?)\\. Was: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/DecayRpcScheduler.java","lineNumber":396,"sourceCode":"\n  private static double[] parseThresholds(String ns, Configuration conf,\n      int numLevels) {\n    int[] percentages = conf.getInts(ns + \".\" +\n        IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY);\n\n    if (percentages.length == 0) {\n      percentages = conf.getInts(ns + \".\" + IPC_DECAYSCHEDULER_THRESHOLDS_KEY);\n      if (percentages.length == 0) {\n        return getDefaultThresholds(numLevels);\n      }\n    } else {\n      LOG.warn(IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY +\n          \" is deprecated. Please use \" +\n          IPC_DECAYSCHEDULER_THRESHOLDS_KEY);\n    }\n\n    if (percentages.length != numLevels-1) {\n      throw new IllegalArgumentException(\"Number of thresholds should be \" +\n        (numLevels-1) + \". Was: \" + percentages.length);\n    }\n\n    // Convert integer percentages to decimals\n    double[] decimals = new double[percentages.length];\n    for (int i = 0; i < percentages.length; i++) {\n      decimals[i] = percentages[i] / 100.0;\n    }\n\n    return decimals;\n  }\n\n  private Set<String> parseServiceUserNames(String ns, Configuration conf) {\n    Collection<String> collection = conf.getStringCollection(\n        ns + \".\" + IPC_DECAYSCHEDULER_SERVICE_USERS_KEY);\n    return new HashSet<>(collection);\n  }\n","sourceCodeStart":378,"sourceCodeEnd":414,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/DecayRpcScheduler.java#L378-L414","documentation":"parseThresholds reads integer percentages from <ns>.decay-scheduler.thresholds (deprecated fallback <ns>.faircallqueue.decay-scheduler.thresholds). For numLevels priority queues exactly numLevels-1 thresholds are needed — each threshold is the cumulative-usage boundary between adjacent queues — so any other count throws IllegalArgumentException with the expected number in the message at scheduler construction.","triggerScenarios":"Configuring 4 priority levels (ipc.<port>.callqueue-priority-levels=4) but supplying 4 thresholds instead of 3; supplying a single threshold where numLevels-1 > 1; leaving stale thresholds in config after changing the level count; trailing/doubled commas producing an unexpected element count.","commonSituations":"Changing callqueue-priority-levels during a tuning exercise without updating decay-scheduler.thresholds in lockstep; copying example configs whose level count differs from the local setting.","solutions":["Count your priority levels N and set exactly N-1 ascending integer percentages, e.g., N=4 -> '10,40,80'.","Or remove decay-scheduler.thresholds entirely to use getDefaultThresholds(numLevels).","After editing, re-check for stray commas/whitespace in the comma-separated list."],"exampleFix":"// before (core-site.xml)\n<property><name>ipc.8020.callqueue-priority-levels</name><value>4</value></property>\n<property><name>ipc.8020.decay-scheduler.thresholds</name><value>10,40,80,90</value></property>\n<!-- expects 3 thresholds, got 4 -> IllegalArgumentException -->\n\n// after\n<property><name>ipc.8020.callqueue-priority-levels</name><value>4</value></property>\n<property><name>ipc.8020.decay-scheduler.thresholds</name><value>10,40,80</value></property>","handlingStrategy":"validation","validationCode":"int levels = conf.getInt(\"ipc.\" + port + \".callqueue-priority-levels\", 1);\nint[] t = conf.getInts(\"ipc.\" + port + \".decay-scheduler.thresholds\");\nif (t.length > 0 && t.length != levels - 1) {\n  throw new ConfigException(\"decay-scheduler.thresholds needs \" + (levels - 1)\n      + \" entries for \" + levels + \" levels, got \" + t.length);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Change callqueue-priority-levels and decay-scheduler.thresholds together (levels-1 entries).","Use ascending percentages and review ordering after every level change.","Cover the pair of keys in config-template tests."],"tags":["hadoop","ipc","decay-scheduler","thresholds","config","validation"],"backgroundTag":"config-validation-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}