{"record":{"id":"ea26e2e265447bbd","repo":"apache/skywalking","slug":"incompatible-ranks-size-value-getranks-lengt-ea26e2","errorCode":null,"errorMessage":"Incompatible ranks size = [{value.getRanks().length}] for current PercentileFunction[{ranks.size()}]","messagePattern":"Incompatible ranks size = \\[(.+?)\\] for current PercentileFunction\\[(.+?)\\]","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/sum/SumHistogramPercentileFunction.java","lineNumber":113,"sourceCode":"\n    @Override\n    public void accept(final MeterEntity entity, final PercentileArgument value) {\n        if (summation.size() > 0) {\n            if (!value.getBucketedValues().isCompatible(summation)) {\n                throw new IllegalArgumentException(\n                    \"Incompatible BucketedValues [\" + value + \"] for current PercentileFunction[\" + summation + \"]\");\n            }\n        }\n\n        for (final int rank : value.getRanks()) {\n            if (rank <= 0) {\n                throw new IllegalArgumentException(\"Illegal rank value \" + rank + \", must be positive\");\n            }\n        }\n\n        if (ranks.size() > 0) {\n            if (ranks.size() != value.getRanks().length) {\n                throw new IllegalArgumentException(\n                    \"Incompatible ranks size = [\" + value.getRanks().length + \"] for current PercentileFunction[\" + ranks\n                        .size() + \"]\");\n            } else {\n                for (final int rank : value.getRanks()) {\n                    if (!ranks.include(rank)) {\n                        throw new IllegalArgumentException(\n                            \"Rank \" + rank + \" doesn't exist in the previous ranks \" + ranks);\n                    }\n                }\n            }\n        } else {\n            for (final int rank : value.getRanks()) {\n                ranks.add(rank);\n            }\n        }\n\n        this.entityId = entity.id();\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/meter/function/sum/SumHistogramPercentileFunction.java#L95-L131","documentation":"After the first accept() locks the rank IntList for a sum_histogram_percentile metric in the current window, SumHistogramPercentileFunction requires every subsequent input to carry exactly the same NUMBER of ranks. This branch throws when value.getRanks().length differs from the locked ranks.size(), even if the values overlap.","triggerScenarios":"First input in the window is percentile(50, 75, 90) (3 ranks) and a later input for the same metric is percentile(50, 75, 90, 99) (4 ranks) — size mismatch, 4 != 3.","commonSituations":"Adding/removing a rank in MAL config and rolling it out while the old config still reports; two MAL rules with the same metric name but different rank counts; multi-cluster OAP nodes with different config versions.","solutions":["Make the rank list identical (same values AND same count) across all producers of the metric","Restart the whole OAP cluster after changing ranks so the next window re-locks the set","Search all MAL rule files for the metric name and deduplicate/align the percentile expressions"],"exampleFix":"# before — inconsistent counts across rules\npercentile(50, 75) -> sum_histogram_percentile\npercentile(50, 75, 90) -> sum_histogram_percentile\n# after\npercentile(50, 75, 90) -> sum_histogram_percentile  (both rules)","handlingStrategy":"validation","validationCode":"int[] incoming = argument.getRanks();\nIntList locked = function.getRanks();\nif (locked.size() > 0 && locked.size() != incoming.length) {\n    log.warn(\"Rank count {} != locked {} for {}; drop\", incoming.length, locked.size(), metricName);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { function.accept(entity, argument); } catch (IllegalArgumentException e) { log.warn(...); /* drop sample, keep pipeline alive */ }","preventionTips":["Pin rank lists with a shared config constant so counts cannot drift between rules","Restart the entire OAP cluster simultaneously after rank changes","Diff MAL rule sets across OAP nodes during rolling upgrades to catch divergent configs"],"tags":["meter-function","mal","percentile","metric-config","validation"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}