microsoft/FASTER · error · FasterException

Invalid length of record found

Error message

Invalid length of record found: {entryLength} at address {currentAddress}

What it means

While scanning, a record header declared a length whose record would run past the end of the page (FasterLogIterator.cs:842). Since FasterLog never splits records, a header claiming such a size means the page is corrupt; the iterator advances past the header and throws to signal the corruption.

Solutions

  1. Limit scans to the committed range (CommittedUntilAddress) so garbage beyond the tail is never interpreted.
  2. Recover from a checkpoint taken before the corrupt page; replace damaged device files.
  3. Ensure reader and writer use the same FasterLog version (header layout compatibility).
  4. Back up and recreate the log if the corruption is persistent; check disk health.

Example fix

// before
using var iter = log.Scan(oldAddress, Constants.kInvalidAddress);

// after
using var iter = log.Scan(oldAddress, log.CommittedUntilAddress);
Defensive patterns

Strategy: validation

Validate before calling

if (endAddress > log.CommittedUntilAddress) endAddress = log.CommittedUntilAddress;

Try / catch

try { Scan(); } catch (FasterException ex) when (ex.Message.StartsWith("Invalid length of record found")) { /* mark page corrupt; recover from checkpoint */ }

Prevention

When it happens

Trigger: Iterating a log with bit rot / torn writes so a stale or garbage entry length appears; scanning a region written by an incompatible FasterLog version whose header layout differs; reading beyond the committed tail into uninitialized memory reinterpreted as a header.

Common situations: Device-level corruption or incomplete flush after crash; mixing log files from different library versions; pointing an iterator at the wrong address range of a reused page.

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 microsoft/FASTER@321d872eab (2026-09-15). Data as JSON: /api/errors/08c889aee627a82e. Report an issue: GitHub.

Appendix: source

Thrown at cs/src/core/FasterLog/FasterLogIterator.cs:842

                        if (pageOffset == 0)
                            throw new FasterException("Uninitialized page found during scan at page " + (currentAddress >> allocator.LogPageSizeBits));
                    }
                    continue;
                }

                // commit records have negative length fields
                if (entryLength < 0)
                {
                    commitRecord = true;
                    entryLength = -entryLength;
                }

                int recordSize = headerSize + Align(entryLength);
                if (_currentOffset + recordSize > allocator.PageSize)
                {
                    currentAddress += headerSize;
                    if (Utility.MonotonicUpdate(ref nextAddress, currentAddress, out _))
                        throw new FasterException("Invalid length of record found: " + entryLength + " at address " + currentAddress);
                    continue;
                }

                // Verify checksum if needed
                if (currentAddress < _headAddress)
                {
                    if (!fasterLog.VerifyChecksum((byte*)physicalAddress, entryLength))
                    {
                        currentAddress += headerSize;
                        if (Utility.MonotonicUpdate(ref nextAddress, currentAddress, out _))
                            throw new FasterException("Invalid checksum found during scan, skipping");
                        continue;
                    }
                }

                if ((currentAddress & allocator.PageSizeMask) + recordSize == allocator.PageSize)
                    currentAddress = (1 + (currentAddress >> allocator.LogPageSizeBits)) << allocator.LogPageSizeBits;
                else

View on GitHub (pinned to 321d872eab)