apache/cassandra · error · IndexOutOfBoundsException
The requested position exceeds the index length
Error message
The requested position exceeds the index length
What it means
BigTableKeyReader.indexPosition(long) seeks the Index.db reader to an arbitrary position. It validates the requested position against the index file length and throws IndexOutOfBoundsException('The requested position exceeds the index length') when the position lies past EOF, preventing a failed seek on a corrupt or stale index reference.
Source
Thrown at src/java/org/apache/cassandra/io/sstable/format/big/BigTableKeyReader.java:184
public RowIndexEntry rowIndexEntry() {
assert detailed;
return rowIndexEntry;
}
public FileHandle indexFile() {
return indexFile;
}
public long indexPosition()
{
return indexFileReader.getFilePointer();
}
public void indexPosition(long position) throws IOException
{
if (position > indexLength())
throw new IndexOutOfBoundsException("The requested position exceeds the index length");
indexFileReader.seek(position);
key = null;
keyPosition = 0;
dataPosition = 0;
advance();
}
public long indexLength()
{
return indexFileReader.length();
}
@Override
public void reset() throws IOException
{
indexFileReader.seek(initialPosition);
key = null;
keyPosition = 0;View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Run `nodetool scrub` on the table to rebuild/skip corrupt index structures.
- Remove the suspect SSTable and run repair to restore good data.
- Validate Index.db/Summary.db with `sstableverify`/`sstablemetadata` offline tools.
- Check for disk-level truncation and hardware issues; verify file sizes against backup copies.
Example fix
// before: blindly seeking into index
keyReader.indexPosition(entry.position); // throws if beyond EOF
// after: guard the seek
if (entry.position <= keyReader.indexLength())
keyReader.indexPosition(entry.position);
else
handleCorruptIndex(entry); Defensive patterns
Strategy: validation
Validate before calling
// Java: bounds-check before seek
if (position >= 0 && position <= keyReader.indexLength())
keyReader.indexPosition(position);
else
logCorruptIndexEntry(position); Type guard
boolean validIndexPos = (position >= 0 && position <= indexLength());
Try / catch
try {
keyReader.indexPosition(pos);
} catch (IndexOutOfBoundsException e) {
logger.warn("Index position {} beyond index length {} — index corrupt", pos, keyReader.indexLength());
} Prevention
- Run verify/scrub regularly to detect index corruption early
- Never read SSTables while they are being compacted away
- Validate index/summary with offline sstable tools before heavy analysis jobs
When it happens
Trigger: A caller (e.g. KeyReader reset/seek, scrubber or verifier following an index entry) supplies a position greater than indexLength() — typically from a corrupted Index.db/Summary.db entry, a stale cached first/last index bound, or a file truncated concurrently.
Common situations: Corrupt or truncated Index.db after crash/disk failure; summary entries pointing beyond the index after an interrupted compaction; reading an SSTable whose file was replaced/truncated underneath a live reader.
Related errors
- Invalid negative chunk index %d with position %d
- The requested position exceeds the index length
- Failed to read partition index
- Key from data file (%s) does not match key from index file (
- First partition does not match index
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/0390fe1b742576e4.
Report an issue: GitHub.