apache/cassandra · error

Failed to seek to next partition position

Error message

Failed to seek to next partition position %d

What it means

seekToNextPartition failed to position the data reader at the position taken from the index (nextPartitionPositionFromIndex). The scrubber logs the error, increments badPartitions, and updates the index cursor to try the following partition, skipping over the unreadable region.

Solutions

  1. Let the scrubber skip ahead and finish; bad partitions are counted and reported
  2. Run `nodetool repair` afterwards to restore skipped partitions from replicas
  3. Replace the sstable pair (Data+Index) from a snapshot or healthy replica
  4. Validate data file length vs index entries with `nodetool verify` before scrubbing

Example fix

// before: seek to bogus index position fails
outputHandler.warn(th, "Failed to seek to next partition position %d", nextPartitionPositionFromIndex);
// after: bound-check positions against data file length
if (nextPartitionPositionFromIndex > dataFile.length())
    outputHandler.warn("Skipping invalid index position %d > %d", nextPartitionPositionFromIndex, dataFile.length());
Defensive patterns

Strategy: try-catch

Validate before calling

long pos = nextPartitionPositionFromIndex;
if (pos < 0 || pos > dataFile.length())
    logger.warn("Index position {} out of bounds for data file length {}", pos, dataFile.length());

Try / catch

try {
    dataFile.seek(nextPartitionPositionFromIndex);
} catch (IOException e) {
    badPartitions++;
    logger.warn("Cannot seek to {}; advancing index cursor", nextPartitionPositionFromIndex, e);
    updateIndexKey();
}

Prevention

When it happens

Trigger: seekToNextPartition (called from scrubInternal) catches a Throwable after dataFile.seek(nextPartitionPositionFromIndex) or during the surrounding read — position out of file bounds, I/O error, or a corrupt index-derived position.

Common situations: Index positions pointing past a truncated data file, corrupt row-index entries giving bogus offsets, disk I/O failures mid-scrub.

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/bef7ade76595c7f2. Report an issue: GitHub.

Appendix: source

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

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

    private boolean seekToNextPartition()
    {
        while (nextPartitionPositionFromIndex < dataFile.length())
        {
            try
            {
                dataFile.seek(nextPartitionPositionFromIndex);
                return true;
            }
            catch (Throwable th)
            {
                throwIfFatal(th);
                outputHandler.warn(th, "Failed to seek to next partition position %d", nextPartitionPositionFromIndex);
                badPartitions++;
            }

            updateIndexKey();
        }

        return false;
    }

    @Override
    protected void throwIfCannotContinue(DecoratedKey key, Throwable th)
    {
        if (isIndex)
        {
            outputHandler.warn("An error occurred while scrubbing the partition with key '%s' for an index table. " +
                               "Scrubbing will abort for this table and the index will be rebuilt.", keyString(key));
            throw new IOError(th);
        }

View on GitHub (pinned to 88fd0f6a0e)