{"record":{"id":"42630ed922b9058d","repo":"Netflix/Hystrix","slug":"percentile-percentile-is-not-currently-cached","errorCode":null,"errorMessage":"Percentile ({percentile}) is not currently cached","messagePattern":"Percentile \\((.+?)\\) is not currently cached","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hystrix-core/src/main/java/com/netflix/hystrix/metric/CachedValuesHistogram.java","lineNumber":139,"sourceCode":"            case 4000: return p40;\n            case 4500: return p45;\n            case 5000: return p50;\n            case 5500: return p55;\n            case 6000: return p60;\n            case 6500: return p65;\n            case 7000: return p70;\n            case 7500: return p75;\n            case 8000: return p80;\n            case 8500: return p85;\n            case 9000: return p90;\n            case 9500: return p95;\n            case 9900: return p99;\n            case 9950: return p99_5;\n            case 9990: return p99_9;\n            case 9995: return p99_95;\n            case 9999: return p99_99;\n            case 10000: return p100;\n            default: throw new IllegalArgumentException(\"Percentile (\" + percentile + \") is not currently cached\");\n        }\n    }\n\n    public long getTotalCount() {\n        return totalCount;\n    }\n\n    public static Histogram getNewHistogram() {\n        return new Histogram(NUMBER_SIGNIFICANT_DIGITS);\n    }\n}\n","sourceCodeStart":121,"sourceCodeEnd":151,"githubUrl":"https://github.com/Netflix/Hystrix/blob/5ce3bc58c38e7ca60ef2fe0e516e390e294ad941/hystrix-core/src/main/java/com/netflix/hystrix/metric/CachedValuesHistogram.java#L121-L151","documentation":"CachedValuesHistogram.getCachedPercentile(percentile) only serves percentiles it precomputed in basis points: 0, 2500, 5000, 7000, 7500, 8000, 8500, 9000, 9500, 9900, 9950, 9990, 9995, 9999, 10000 (i.e. mean, p25–p100 in the fixed step set). Any other integer throws IllegalArgumentException('Percentile (x) is not currently cached'). Arbitrary percentiles require the underlying HdrHistogram, not the cached accessor.","triggerScenarios":"Calling getCachedPercentile() with values like 1, 990, 9905, 1234, or 9990 vs 99900 — anything not in the switch; common when passing a percentile as percent (99) instead of basis points (9900), or requesting p98/p99.9 variants that were never cached.","commonSituations":"Custom dashboards/metrics publishers asking for percent values instead of basis points (99 instead of 9900); requesting uncached percentiles like p98; code ported from getValueAtPercentile (HdrHistogram, arbitrary values) to the cached fast path.","solutions":["Pass basis points: 9900 for p99, 9990 for p99.9 — check against the switch's cached set","Use the full HdrHistogram API (histogram.getValueAtPercentile(x)) for arbitrary percentiles instead of the cached accessor","Use the public HystrixCommandMetrics APIs (getExecutionTimePercentile) which translate correctly"],"exampleFix":"// before\nlong p99 = stream.getLatest().getCachedPercentile(99); // percent, throws\n// after\nlong p99 = stream.getLatest().getCachedPercentile(9900); // basis points (99.00%)","handlingStrategy":"validation","validationCode":"static boolean isCachedPercentile(int bps) {\n  return bps==0||bps==2500||bps==5000||bps==7000||bps==7500||bps==8000||bps==8500\n      ||bps==9000||bps==9500||bps==9900||bps==9950||bps==9990||bps==9995||bps==9999||bps==10000; }\nif (!isCachedPercentile(p)) p = 9900; // or use full histogram","typeGuard":"null","tryCatchPattern":"Not worth catching — validate the basis-point value or use histogram.getValueAtPercentile() for arbitrary percentiles.","preventionTips":["Remember the API takes basis points (9900 = 99%), not percent","Use getValueAtPercentile on the underlying HdrHistogram for non-cached percentiles"],"tags":["java","hystrix","metrics","percentiles","hdrhistogram"],"backgroundTag":null,"analyzedSha":"5ce3bc58c38e7ca60ef2fe0e516e390e294ad941","analyzedAt":"2026-08-14T10:55:35.600Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}