Log sequence number
A log sequence number is an engine-defined identifier that orders log-related records or operations, without universally encoding their physical log positions.
PostgreSQL represents an LSN as a byte offset in WAL. Insert, write and durable-flush positions have different meanings: knowing an LSN does not establish that its record is durable. In PostgreSQL, subtracting compatible positions gives bytes, not transaction count or elapsed time; retain the engine, timeline and observed progress stage when comparing positions. XFS instead encodes a 32-bit cycle and 32-bit block position; the latter counts 512-byte basic blocks. [7] [8] Raw encoded subtraction across cycles is not a byte-distance calculation.
An equal numeric LSN after a history fork is not proof of equal WAL contents. Cluster identity and timeline ancestry are separate from this byte position. [5]
Logical order: Deuteronomy assigns operation LSNs before execution and logs completed operations at separate physical log positions. Concurrent nonconflicting operations can reach the log out of LSN order. Its stable-log frontier therefore covers a completed prefix, not merely the highest LSN present on disk. [10]
Relations
- related
- Write-ahead log, Database checkpoint, Replication lag, Synchronous replication, Asynchronous replication, Compensation log record, Page LSN, XFS relogging, PostgreSQL timeline, Timeline history file (PostgreSQL), LLAMA
Citations
- PostgreSQL 18: timeline history and recovery branches
- Linux v6.16: XFS Logging Design, log space accounting and re-logging
- Linux v6.16: xfs_log_format.h, CYCLE_LSN and BLOCK_LSN
- Levandoski, Lomet, Mokbel and Zhao. Deuteronomy: Transaction Support for Cloud Data. CIDR 2011, pp. 123-133; sections 4.5-4.5.2.