DEV Community

leo
leo

Posted on

OpenGauss common log introduction: WAL log

WAL log
WAL (Write Ahead Log, also known as Xlog) is a standard method for implementing transaction logs, and the corresponding logs must be persisted before persistent modification of data files (the carriers of tables and indexes). If a data file is to be modified, it must be done after these modification operations have been recorded in the log file, that is, after the log records describing these changes are flushed to permanent storage. When the system crashes, you can use the WAL log to restore openGauss.

Log file storage path

Taking a database node as an example, it is in the "/gaussdb/data/data_dn/pg_xlog" directory by default.

Where "/gaussdb/data/data_dn" represents the data directory of the openGauss node.

Log file naming format

Log files are stored in the form of segment files, each segment is 16MB, and divided into several pages, each page is 8KB. The naming instructions for the WAL log are as follows: the name of a segment file consists of 24 hexadecimal characters, which are divided into three parts, and each part consists of 8 hexadecimal characters. The first part represents the timeline, the second part represents the log file label, and the third part represents the segment label of the log file. Timelines start with 1, log file numbers and log file segment numbers start with 0.

For example, the first transaction log file on the system is 000000010000000000000000.

Explanation: These numbers are generally used sequentially (it will take a very long time to use up all available numbers), but there are also cases of circular use.

Description of log content

The content of the WAL log depends on the type of recorded transaction, and the WAL log can be used for recovery when the system crashes.

By default, openGauss will first read the WAL log for recovery each time it starts.

maintenance advice

WAL logs play an important role in abnormal database recovery. It is recommended to back up WAL logs regularly.

Top comments (0)