{"record":{"id":"322ac1c5ad1ebf76","repo":"apache/cassandra","slug":"invalid-lookback-distribution-max-value-is-maxv","errorCode":null,"errorMessage":"Invalid lookback distribution; max value is ${maxValue}, but series only ranges from ${writeCount} to ${start+totalCount}","messagePattern":"Invalid lookback distribution; max value is (.+?), but series only ranges from (.+?) to (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/generate/SeedManager.java","lineNumber":237,"sourceCode":"                    return;\n                if (head.getKey().seed == min + 1 && this.writeCount.compareAndSet(min, min + 1))\n                {\n                    afterMin.remove(head.getKey());\n                    continue;\n                }\n                return;\n            }\n        }\n\n        private class LookbackReadGenerator extends Generator\n        {\n            final Distribution lookback;\n\n            public LookbackReadGenerator(Distribution lookback)\n            {\n                this.lookback = lookback;\n                if (lookback.maxValue() > start + totalCount)\n                    throw new IllegalArgumentException(\"Invalid lookback distribution; max value is \" + lookback.maxValue()\n                                                       + \", but series only ranges from \" + writeCount + \" to \" + (start + totalCount));\n            }\n\n            public Seed next(int visits)\n            {\n                long lookback = this.lookback.next();\n                long range = writeCount.get();\n                long startOffset = range - lookback;\n                if (startOffset < 0)\n                {\n                    if (range == totalCount && !wrap)\n                        return null;\n                    startOffset = range == 0 ? 0 : lookback % range;\n                }\n                return new Seed(start + startOffset, visits);\n            }\n        }\n","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/generate/SeedManager.java#L219-L255","documentation":"LookbackReadGenerator validates at construction that the lookback distribution's maximum value does not exceed the number of keys that will exist in the series (start + totalCount). A lookback larger than the written range would read keys that are never written, so the constructor throws IllegalArgumentException naming the distribution max and the actual series range.","triggerScenarios":"cassandra-stress read command where the lookback distribution's max (e.g. lookback=uniform(1..100000)) exceeds start+totalCount for the configured series size (e.g. n=50000 with start=0).","commonSituations":"Running reads against a stress series smaller than the lookback window; forgetting that lookback is relative to total keys written; running read-only stress without a prior population run of enough rows.","solutions":["Increase the series size (-n) so it is at least as large as the lookback distribution's max","Reduce the lookback distribution max, e.g. lookback=uniform(1..50000) when n=50000","Populate the keyspace with a write run first so start+totalCount covers the lookback range"],"exampleFix":"// before\nstress read n=1000 lookback=uniform(1..5000)\n// after\nstress read n=5000 lookback=uniform(1..5000)","handlingStrategy":"validation","validationCode":"if (lookback.maxValue() > seriesStart + seriesTotalCount)\n    throw new IllegalArgumentException(\"lookback max \" + lookback.maxValue() + \" exceeds series range\");","typeGuard":"boolean lookbackFits(Distribution lookback, long start, long totalCount) { return lookback.maxValue() <= start + totalCount; }","tryCatchPattern":"try { new LookbackReadGenerator(lookback); } catch (IllegalArgumentException e) { log.error(\"Adjust -n or lookback: {}\", e.getMessage()); }","preventionTips":["Ensure the series size (-n) is >= the lookback distribution max","Populate keys with a write run before lookback reads","Keep lookback max comfortably below total keys"],"tags":["cli","configuration","distribution"],"backgroundTag":"value-out-of-range","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}