← Back to Case Library

DurableWriterAutoAST: corrupted length prefix causes incomplete_record replay halt

DomainDURABLEWRITERAUTOAST ImpactHigh
Error Signature
durablewriterautoast:durablewriterautoast:reason-incomplete-record-position-totalentrylength-size

Corrupted 4-byte UInt32BE length prefix at byte offset 17,525,176 in the .qkey durability log encodes 1.35 GB as a record length (file is only 75.7 MB), causing the JS reader to halt replay on every pass with reason incomplete_record.

Root Cause

Corrupted 4-byte UInt32BE length prefix at byte offset 17,525,176 within the QKeyDB .qkey durability log encodes 1,412,510,010 bytes (~1.35 GB) as the next record length. The file is only 79,362,903 bytes (~75.7 MB). The DurableWriterAutoAST JS reader in DurableWriter.js detects outOfBounds (position + totalEntryLength > stats.size), attempts a 64 KiB resync scan for known magic bytes (QKHEAD, QKANCH, QKB1), finds no valid frame candidate, logs incomplete_record error, and halts replay. The error recurs on every replay pass because the file is never repaired (210 occurrences).

Solution Steps

  1. Back up and truncate the .qkey durability log at the corruption offset (byte 17,525,176): cp <file>.qkey <file>.qkey.bak then truncate -s 17525176 <file>.qkey. This discards the corrupted record and stops the incomplete_record replay loop.
  2. In DurableWriter.js reader: add a pre-flight sanity check on the decoded UInt32BE length — if decodedLength exceeds (fileSize - currentOffset) immediately enter resync mode instead of attempting the read.
  3. Add a maximum-skip-count guard to the resync loop: if no valid frame is found within 64 KiB, log the unrecoverable offset, write a repair marker to a sidecar .corrupt file, and allow replay to continue from the end of the scan window rather than halting entirely.

Validation

[object Object]

Ecosystem: durablewriterautoast

License: CC-BY-4.0

Last updated: May 21, 2026

Case ID: dbf5fe04-7249-49e2-babf-8d07158ec485