apache/cassandra · error · IllegalArgumentException

sample range is invalid

Error message

sample range is invalid

What it means

SeedManager validates the sample range derived from the insert 'revisit' distribution at construction. sampleOffset is the min of the distribution's min/max values and sampleSize the span between them; if the distribution can produce negative values or the span exceeds Integer.MAX_VALUE, no valid sample window exists and the constructor throws IllegalArgumentException.

Source

Thrown at tools/stress/src/org/apache/cassandra/stress/generate/SeedManager.java:50

    final Distribution visits;
    final Generator writes;
    final Generator reads;
    final ConcurrentHashMap<Long, Seed> managing = new ConcurrentHashMap<>();
    final LockedDynamicList<Seed> sampleFrom;
    final Distribution sample;
    final long sampleOffset;
    final int sampleSize;
    final long sampleMultiplier;
    final boolean updateSampleImmediately;

    public SeedManager(StressSettings settings)
    {
        Distribution tSample = settings.insert.revisit.get();
        this.sampleOffset = Math.min(tSample.minValue(), tSample.maxValue());
        long sampleSize = 1 + Math.max(tSample.minValue(), tSample.maxValue()) - sampleOffset;
        if (sampleOffset < 0 || sampleSize > Integer.MAX_VALUE)
            throw new IllegalArgumentException("sample range is invalid");

        // need to get a big numerical range even if a small number of discrete values
        // one plus so we still get variation at the low order numbers as well as high
        this.sampleMultiplier = 1 + Math.round(Math.pow(10D, 22 - Math.log10(sampleSize)));

        Generator writes, reads;
        if (settings.generate.sequence != null)
        {
            long[] seq = settings.generate.sequence;
            if (settings.generate.readlookback != null)
            {
                LookbackableWriteGenerator series = new LookbackableWriteGenerator(seq[0], seq[1], settings.generate.wrap, settings.generate.readlookback.get(), sampleMultiplier);
                writes = series;
                reads = series.reads;
            }
            else
            {
                writes = reads = new SeriesGenerator(seq[0], seq[1], settings.generate.wrap, sampleMultiplier);

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Fix the revisit distribution so its minimum value is >= 0 and max-min <= Integer.MAX_VALUE
  2. Use a smaller discrete or bounded distribution, e.g. revisit=uniform(1..1000000)
  3. If modeling huge keyspaces, split the stress run into multiple runs with offset ranges instead of one huge distribution

Example fix

// before
settings.insert.revisit = uniform(-100..1000)
// after
settings.insert.revisit = uniform(0..1000)
Defensive patterns

Strategy: validation

Validate before calling

Distribution t = settings.insert.revisit.get();
long offset = Math.min(t.minValue(), t.maxValue());
long size = 1 + Math.max(t.minValue(), t.maxValue()) - offset;
if (offset < 0 || size > Integer.MAX_VALUE) throw new IllegalArgumentException("revisit distribution range invalid");

Type guard

boolean isValidSampleRange(Distribution d) { return Math.min(d.minValue(), d.maxValue()) >= 0 && (1 + Math.max(d.minValue(), d.maxValue()) - Math.min(d.minValue(), d.maxValue())) <= Integer.MAX_VALUE; }

Try / catch

try { SeedManager sm = new SeedManager(settings); } catch (IllegalArgumentException e) { log.error("Bad revisit distribution: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Running cassandra-stress with an insert revisit distribution (e.g. revisit=uniform(-1..10) or a huge range like gaussian(0..3000000000)) whose minimum value is negative or whose min..max span exceeds 2^31-1.

Common situations: Typing a revisit/visit distribution spec with negative lower bounds in stress profiles; using enormous distribution ranges to model very large keyspaces; copy-pasted profile YAML with typos in distribution arguments.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/64bd71ac5f36ac78. Report an issue: GitHub.