apache/cassandra · warning

Failed to advance to the next index position. Index is…

Error message

Failed to advance to the next index position. Index is corrupted. Continuing without the index. Last position read is %d.

What it means

While scrubbing with the BTI partition index, the scrubber advances the index iterator between partitions. If advancing throws (the index entries point at unreadable or inconsistent positions), the scrubber logs this warning, closes the index, and continues scrubbing the data file sequentially without index guidance. The message includes the last data position successfully read from the index to aid diagnosis.

Solutions

  1. Continue the scrub — it proceeds without the index and quarantines/repairs bad partitions.
  2. After scrub completes, run `nodetool compact` on the table to rebuild a clean index.
  3. Restore the affected sstables from a verified backup or repair the node with `nodetool repair`.
  4. Investigate storage-layer corruption (fsck, SMART, RAID checks) on the data directory.

Example fix

// Operational fix, not code:
// before: scrub warns 'Failed to advance to the next index position' and drops the index
// after: rebuild the sstable/index and verify
$ nodetool scrub <keyspace> <table>
$ nodetool compact <keyspace> <table>
Defensive patterns

Strategy: fallback

Validate before calling

// Check sstable components exist and are non-trivial before scrub
$ sstablemetadata <path>/xx-Data.db   # errors out on unreadable/corrupt sstable
$ ls -l <path>/xx-Index.db            # should not be 0 bytes when Data.db is non-empty

Prevention

When it happens

Trigger: `nodetool scrub` iterating PartitionIndex entries on a BTI sstable where indexIterator.advance() throws due to truncated or corrupt index blocks, bad pointers in the trie, or data/index length mismatch.

Common situations: Incomplete compaction or flush leaves after a crash; corrupt sstables restored from backups; disks with silent corruption; manually truncated sstable files.

Understand the failure class

Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/io/sstable/format/bti/BtiTableScrubber.java:154

            // size of the partition (including partition key)
            long dataSizeFromIndex = -1;
            ByteBuffer currentIndexKey = null;
            if (indexAvailable())
            {
                currentIndexKey = indexIterator.key();
                dataStartFromIndex = indexIterator.dataPosition();
                if (!indexIterator.isExhausted())
                {
                    try
                    {
                        indexIterator.advance();
                        if (!indexIterator.isExhausted())
                            dataSizeFromIndex = indexIterator.dataPosition() - dataStartFromIndex;
                    }
                    catch (Throwable th)
                    {
                        throwIfFatal(th);
                        outputHandler.warn(th,
                                           "Failed to advance to the next index position. Index is corrupted. " +
                                           "Continuing without the index. Last position read is %d.",
                                           indexIterator.dataPosition());
                        indexIterator.close();
                        indexIterator = null;
                        currentIndexKey = null;
                        dataStartFromIndex = -1;
                        dataSizeFromIndex = -1;
                    }
                }
            }

            String keyName = key == null ? "(unreadable key)" : keyString(key);
            outputHandler.debug("partition %s is %s", keyName, FBUtilities.prettyPrintMemory(dataSizeFromIndex));

            try
            {
                if (key == null)

View on GitHub (pinned to 88fd0f6a0e)