View Source ExWal.Models.RecyclableRecord (ex_wal v0.3.0)
The recyclyable chunk format is similar to the legacy format, but extends the chunk header with an additional log number field. This allows reuse (recycling) of log files which can provide significantly better performance when syncing frequently as it avoids needing to update the file metadata. Additionally, recycling log files is a prequisite for using direct IO with log writing. The recyclyable format is:
+----------+-----------+-----------+----------------+--- ... ---+ | CRC (4B) | Size (2B) | Type (1B) | Log number (4B)| Payload | +----------+-----------+-----------+----------------+--- ... ---+
Recyclable chunks are distinguished from legacy chunks by the addition of 4 extra "recyclable" chunk types that map directly to the legacy chunk types (i.e. full, first, middle, last). The CRC is computed over the type, log number, and payload.
The wire format allows for limited recovery in the face of data corruption: on a format error (such as a checksum mismatch), the reader moves to the next block and looks for the next full or first chunk.
Summary
Types
@type t() :: %ExWal.Models.RecyclableRecord{ crc: non_neg_integer(), log_number: non_neg_integer(), payload: binary(), size: non_neg_integer(), type: non_neg_integer() }