In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "Analysis of the Internal structure of WAL segment file in PostgreSQL". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
WAL segment file
The WAL segment file is divided into N page (Block), each page size is 8K, the corresponding data structure of the header of the first page is XLogLongPageHeaderData, and the corresponding data structure of the header of other page is XLogPageHeaderData. After header, there are N XLOG Record.
XLOG Record
XLOG Record consists of two parts. The first part is fixed size, and the corresponding structure is XLogRecord;. The second part is XLOG Record data.
XLOG Record data
XLOG Record data consists of the following parts:
1.0.. N XLogRecordBlockHeader, one block data for each XLogRecordBlockHeader
Note: if the BKPBLOCK_HAS_IMAGE flag is set, the XLogRecordBlockHeader structure is followed by the XLogRecordBlockImageHeader structure; if BKPIMAGE_HAS_HOLE and BKPIMAGE_IS_COMPRESSED are set, the XLogRecordBlockCompressHeader structure is followed by the XLogRecordBlockImageHeader
2.XLogRecordDataHeader [Short | Long]: such as data 6624362124887945794
[xdb@localhost] $pg_controldatapg_control version number: 1100Catalog version number: 201809051Database system identifier: 6624362124887945794.
Uint32 xlp_seg_size
[xdb@localhost pg_wal] $hexdump-C 00000001000000042-s 32-n 40000002000000001 |. | 000024
The value is 0x01000000, or 16m
[xdb@localhost ~] $echo $((0x01000000)) 16777216
Uint32 xlp_xlog_blcksz
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 36-n 400000024 00 200000 |. | 00000028 |
The value is 0x00002000, which is 8K
[xdb@localhost ~] $echo $((0x00002000)) 8192
Data from the previous page XLOG Record
Due to insufficient space, the XLOG Record of the previous page continues to store occupied data on this page (xlp_rem_len=0x0F, 16B)
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 40-n 1600000028 31 000000 000000 0000 69 b8 40 25 000000 | 1.i.%. | 000038
XLogRecord
And then there's XLogRecord.
Uint32 xl_tot_len
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 56-n 400000038 4f 000000 | O. | 0000003c
XLOG Record length is 0x0000004F
TransactionId (uint32) xl_xid
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 60-n 40000003c 6b 07 0000 | k. | 00000040
The transaction ID is 0x0000076B, or 1899 of the decimal system
XLogRecPtr (uint64) xl_prev
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 64-n 800000040c0 ff ff 41 01000000 |. A. | 00000048
The offset of the previous XLOG Record, 0x00000001 41FFFFC0
Unit8 xl_info
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 72-n 10000004800 |. | 00000049
The flag bit is 0x00
Unit8 xl_rmid
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 73-n 100000049 0a |. | 0000004a
The resource manager of the record, namely 0x0A
2 bytes of padding
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 74-n 20000004a 0000 |.. | 0000004c
Pg_crc32c (uint32) xl_crc
[xdb@localhost pg_wal] $hexdump-C 000000010000000100000042-s 76-n 40000004c ea 21 d2 50 |. .P | 00000050
CRC parity bit, or 0x50D221EA
This is the end of the content of "WAL segment file Internal structure Analysis in PostgreSQL". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.