Abstract: Pagehack and PG_xlogdump can help us to resolve the page headers and xlog logs of various files in the database fault location.
With the evolution of technology, the data has changed greatly. The data scale has become larger, the data types have become diversified, and the timeliness of data processing has become higher and higher. The GaussDB(DWS) real-time data warehouse is facing both great opportunities and challenges. Also, powerful tools to help us locate various problems.
There are a variety of binary files under the database directory, such as system tables, ordinary tables, indexes and log files, etc., but the problems in the process of database operation, how should we use these files to locate and analyze the problems? Pagehack and PG_xlogdump are our tools to solve the problem, help us in the fault location, parse the page header of various files and xlog log.
Pagehack:
Let’s take a look at the parameters of Pagehack
Here are some of the most common parsing methods:
Pg_filenode.map = pg_filenode.map = pg_filenode.map = pg_filenode.map = pg_filenode.map = pg_filenode.map
Pagehack -f pg_filenode.map -t filenode_map, relfilenode corresponds to the file on disk
(2) In addition to the system table, another common data type is the file of the row memory table. Usually, for storage exceptions, reading exceptions and other problems, we need to query the header file information of the row memory table through pagehack. First connect to DN, query relFilenode (16502) corresponding to the row storage table, go to the data directory corresponding to DN, execute: pagehack -f 16502 -t heap, the result is as follows:
The page header structure is as follows
The meaning of some common information in the page is as follows. For page page details, a blog post will be published to introduce page page structure information
Pd_lsn: LSN of the xlog record written to the last change on the page.
Pd_special: used in index pages, where it points to the start of a special space, and in heap table pages, where it points to the end of a page.
Pd_pagesize_version: pagesize and page layout version number.
T_xmin: Holds the TXID (transaction number) of the transaction inserted into this tuple
T_xmax: Holds the TXID of the transaction that deleted or updated this tuple. If this tuple has not been deleted or updated, t_xmax is set to 0, which is invalid.
T_infomask: Identifies the current status of a tuple.
T_infomask2: indicates the number of HOT link status updates and tuples.
pg_xlogdump:
The GaussDB database uses log files to prevent data loss caused by faults such as power outages. Any modification of the database is recorded in a log called XLOG to the disk. When a problem is located in the database, pg_xlogdump can be used to resolve XLOG logs, including log types, corresponding transaction numbers, modified files, and so on.
The usage of the Pg_xlogdump parameter is as follows:
Pg_xlog = pg_xlog = pg_xlog = pg_xlog = pg_xlog = pg_xlog = pg_xlog = pg_xlog = pg_xlog
1. Part 1 is the TimeLineID,
2. The second part is the logical file ID,
3. Part 3 is the physical file ID
pg_xlogdump ./000000010000000000000004 -n
LSN: indicates the log number
Prev: indicates the previous Xlog record corresponding to this record.
Xid: the XID of the transaction
Desc: indicates the detailed description of a log
Using pg_xlogdump, you can view the Xids and LSNS of operations recorded in Xlog logs. After a database crashes, you can use the Xids to recover and locate errors.
Pagehack and PG_xlogdump are two common tools for locating and analyzing problems. I hope the introduction of these two tools can help us improve efficiency when solving problems again. The detailed information of the page structure designed in this article will be introduced in a special article to deepen our understanding.
This document is shared by AndyCao in GaussDB(DWS) storage series pagehack&pg_xlogdump tool usage summary.
Click to follow, the first time to learn about Huawei cloud fresh technology ~