[KongchangAI]
Concept日志序列号 / Log Sequence Number

LSN

A sequence-number mechanism in the database transaction log that identifies the order of log records. In Hyperscale it is used to determine data page versions and the consistency point for reads.

Timeline (last 90 days)

Nov 19

The WAIT FOR LSN command makes a standby block and wait until its replay progress reaches or exceeds the specified LSN.

Unverified50%
Nov 19

WAL (Write-Ahead Logging) is the core mechanism by which PostgreSQL guarantees transactional durability and replication consistency, and each WAL record has a unique LSN (Log Sequence Number), formatted like 0/0306EE20.

Unverified50%
Nov 19

In the example, after a write operation completes, the application can call pg_current_wal_insert_lsn() to obtain the LSN (for example 0/0306EE20); subsequent requests run WAIT FOR LSN '0/0306EE20' WITH (TIMEOUT '0.1s') before executing a query on the standby, and perform the read operation only after the standby has replayed WAL up to the specified LSN.

Unverified50%
Nov 19

The mechanisms in MySQL equivalent to WAIT FOR LSN are WAIT_FOR_EXECUTED_GTID_SET() and MASTER_POS_WAIT(); although PostgreSQL has no GTID, the WAL LSN provides an equivalent monotonically advancing position identifier, and WAIT FOR LSN is semantically highly similar to MASTER_POS_WAIT().

Unverified50%
Nov 19

For scenarios where session state cannot be maintained (such as stateless HTTP requests), putting the LSN in a cookie is a feasible approach, but security and expiration policies need to be considered.

Unverified50%

All Facts (5)

Source Articles