DEV Community

Raja Rakshak
Raja Rakshak

Posted on

Write Ahead Logging: PostgreSQL

In the event of system failures, the Write Ahead Logging(WAL) protocol assures durability and data recovery. These are the few topics discussed in WAL.

Insertion Operations: Data entered into the database is susceptible to loss in the event of system failures without WAL.

Database recovery and insertion operations: PostgreSQL uses the WAL method to write all modifications as historical information into a transaction log. When a transaction commits or aborts, XLOG records, or WAL data, are written to the in-memory WAL buffer and then flushed to the WAL segment file. Replaying XLOG records from the REDO point, or the location at the most recent checkpoint, is a step in the recovery process.

Full-Page Writes: PostgreSQL allows full-page writes to address failures where the page data on the storage is corrupted. Following a checkpoint, a backup block (full-page image) containing the whole page is written as an XLOG record during the first change of each page.

WAL, Backup, and Replication: While WAL protects against process or operating system failures, file-system or media failures require extra safeguards like online backups and synchronous replication.

WAL segment files, which are generally typically 16 MB in size, are used to separate the transaction log in PostgreSQL. A timelineId and LSN (Log Sequence Number) information are included in the naming convention for WAL segment files.

A WAL segment file is internally divided into pages, with the first page containing a header and all subsequent pages containing XLOG records in descending order.

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay