Documentation
¶
Overview ¶
Command wal-read prints a NornicDB WAL directory as one JSON object per visited entry, for reading a framed, mixed WAL stream by hand.
A WAL directory (see pkg/storage) is not one compressed archive: it is a set of sealed segments plus the active wal.log, each a sequence of length-prefixed frames whose payload may be JSON control records or typed (optionally zstd-compressed) records. This command therefore never treats a file as a single zstd stream and never shells out to a compressor: it walks the directory through storage.VisitWALEntriesAfterFromDir, the same reader recovery and db.txlog use, and renders each entry's payload with storage.EntryPayloadJSON, the WAL's typed display owner.
Usage:
go run ./scripts/wal-read -dir /path/to/wal [-from N] [-to N]
Each output line is one JSON object with seq, timestamp (RFC 3339Nano, UTC), database, kind and payload. payload is the entry's JSON value, not a JSON-escaped string. Bounds are inclusive: -from is the lowest sequence to print (default 1) and -to the highest (default 0, no upper bound). Entries may be out of sequence on disk, so a sequence above -to never stops the scan; it is only skipped.
The command is read-only: it opens no WAL for writing, creates no directory, and never invents a transaction id for an entry that has none. This scope holds only published storage API, so it observes exactly what a recovery reader observes. That reader reports a torn end-of-file as an incomplete write and stops without an error; correcting or masking that limit belongs to pkg/storage, not here.