apache/cassandra · warning

Error reading index file

Error message

Error reading index file

What it means

While advancing the scrubber's index cursor (updateIndexKey), reading the next key/position from the -Index.db failed with a non-fatal Throwable. The scrubber logs the error, nulls the next index key, and treats the end-of-index as the data file length, continuing the scrub without index guidance.

Solutions

  1. Scrub continues without index; afterwards run `nodetool repair` to re-sync data
  2. Replace the sstable from a healthy replica (repair/rebuild) rather than scrubbing degraded
  3. Run `nodetool verify` to confirm the extent of index corruption
  4. Check for disk errors in system logs and address hardware issues first

Example fix

// before: index unreadable, scrub degrades
outputHandler.warn(th, "Error reading index file");
// after: restore the index component before scrub
Files.copy(snapshotIndex, sstable.descriptor.fileFor(Components.PRIMARY_INDEX), REPLACE_EXISTING);
Defensive patterns

Strategy: try-catch

Try / catch

try (RandomAccessReader idx = RandomAccessReader.open(indexFile)) {
    rowIndexEntrySerializer.deserializePositionAndSkip(idx);
} catch (IOException e) {
    logger.warn("Index file unreadable; scrub will proceed without index", e);
}

Prevention

When it happens

Trigger: updateIndexKey (called from scrubInternal and seekToNextPartition) catches a Throwable while calling rowIndexEntrySerializer.deserializePositionAndSkip(indexFile) — corrupt or truncated index file, or an undeserializable index entry.

Common situations: Truncated -Index.db after a crash, bit-rot in index blocks, index written by a format-version-incompatible writer, or a corrupt promoted index entry inside a row index.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/io/sstable/format/big/BigTableScrubber.java:233

        }
    }

    private void updateIndexKey()
    {
        currentIndexKey = nextIndexKey;
        currentPartitionPositionFromIndex = nextPartitionPositionFromIndex;
        try
        {
            nextIndexKey = !indexAvailable() ? null : ByteBufferUtil.readWithShortLength(indexFile);

            nextPartitionPositionFromIndex = !indexAvailable()
                                             ? dataFile.length()
                                             : rowIndexEntrySerializer.deserializePositionAndSkip(indexFile);
        }
        catch (Throwable th)
        {
            JVMStabilityInspector.inspectThrowable(th);
            outputHandler.warn(th, "Error reading index file");
            nextIndexKey = null;
            nextPartitionPositionFromIndex = dataFile.length();
        }
    }

    private boolean indexAvailable()
    {
        return indexFile != null && !indexFile.isEOF();
    }

    private boolean seekToNextPartition()
    {
        while (nextPartitionPositionFromIndex < dataFile.length())
        {
            try
            {
                dataFile.seek(nextPartitionPositionFromIndex);
                return true;

View on GitHub (pinned to 88fd0f6a0e)