log-sequence-number · shipping · also LSN

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.

Related Observatory article: Read on hesela.com

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

  1. PostgreSQL 18: timeline history and recovery branches (accessed 2026-10-12)
  2. Linux v6.16: XFS Logging Design, log space accounting and re-logging (accessed 2026-10-16)
  3. Linux v6.16: xfs_log_format.h, CYCLE_LSN and BLOCK_LSN (accessed 2026-10-16)
  4. Levandoski, Lomet, Mokbel and Zhao. Deuteronomy: Transaction Support for Cloud Data. CIDR 2011, pp. 123-133; sections 4.5-4.5.2. (accessed 2026-11-15)

Further reading

  1. PostgreSQL 18: WAL Internals (accessed 2026-10-12)
  2. PostgreSQL 18: Backup Control Functions, Table 9.97 and notes (accessed 2026-10-12)
  3. WAL, checkpoints and torn pages: three different recovery guarantees (accessed 2026-10-12)
  4. PostgreSQL 18: pg_lsn type (accessed 2026-10-12)
  5. Replication acknowledgements: received, durable, applied (accessed 2026-10-12)
  6. Hesela: XFS delayed logging and commit boundaries (accessed 2026-10-16)

JSON: /data/terms/log-sequence-number.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Log sequence number. Hesela. 2026-11-15. https://hesela.dev/terms/log-sequence-number/