当前位置:网站首页>PostgreSQL source code (7) xlog format
PostgreSQL source code (7) xlog format
2022-07-18 17:23:00 【mingjie】
Log header format
typedef struct XLogPageHeaderData
{
【 For verification magic Numbers 】
uint16 xlp_magic; /* magic value for correctness checks */
【 Flag bit information 】
uint16 xlp_info; /* flag bits, see below */
【 Timeline information 】
TimeLineID xlp_tli; /* TimeLineID of first record on page */
【 The location of the current page in the log file 】
XLogRecPtr xlp_pageaddr; /* XLOG address of this page */
【 Logs are saved across pages , The remaining length of the current page that needs to be saved 】
uint32 xlp_rem_len; /* total len of remaining data for record */
} XLogPageHeaderData;File structure
XLOG RECORD
There are links between logs ,xl_prev Point to the starting position of the previous log , The location of the next log is xl_tot_len Can find , Between logs “ Double linked list ”.
typedef struct XLogRecord
{
【 Journal length 】
uint32 xl_tot_len; /* total len of entire record */
【 Business ID】
TransactionId xl_xid; /* xact id */
【 Last log LSN】
XLogRecPtr xl_prev; /* ptr to previous record in log */
【 The action that produces this record 】
uint8 xl_info; /* flag bits, see below */
【 Log the corresponding resource manager 】
RmgrId xl_rmid; /* resource manager for this record */
/* 2 bytes of padding here, initialize to zero */
pg_crc32c xl_crc; /* CRC for this record */
/* XLogRecordBlockHeaders and XLogRecordDataHeader follow, no padding */
【 Log data information 】
} XLogRecord;xl_info low 4 Bit save flag Information , high 4 Bit saves log action information .
Fourth place :
/*
* If a WAL record modifies any relation files, in ways not covered by the
* usual block references, this flag is set. This is not used for anything
* by PostgreSQL itself, but it allows external tools that read WAL and keep
* track of modified blocks to recognize such special record types.
*/
#define XLR_SPECIAL_REL_UPDATE 0x01
/*
* Enforces consistency checks of replayed WAL at recovery. If enabled,
* each record will log a full-page write for each block modified by the
* record and will reuse it afterwards for consistency checks. The caller
* of XLogInsert can use this value if necessary, but if
* wal_consistency_checking is enabled for a rmgr this is set unconditionally.
*/
#define XLR_CHECK_CONSISTENCY 0x02Senior four : such as HEAP operation , Corresponding 8 Action information
#define XLOG_HEAP_INSERT 0x00
#define XLOG_HEAP_DELETE 0x10
#define XLOG_HEAP_UPDATE 0x20
#define XLOG_HEAP_TRUNCATE 0x30
#define XLOG_HEAP_HOT_UPDATE 0x40
#define XLOG_HEAP_CONFIRM 0x50
#define XLOG_HEAP_LOCK 0x60
#define XLOG_HEAP_INPLACE 0x70
#define XLOG_HEAP_OPMASK 0x70
/*
* When we insert 1st item on new page in INSERT, UPDATE, HOT_UPDATE,
* or MULTI_INSERT, we can (and we do) restore entire page in redo
*/
#define XLOG_HEAP_INIT_PAGE 0x80XLOG RECORD Data format
The data is mainly divided into two parts :
- Page information : There's no actual data , Only information about the page
- Data and information : Follow closely XlogRecordDataHeader Back storage ,
- Actual data <255 byte , Use XLogRecordDataHeaderShort, use 1 Byte save data length
- Otherwise use XLogRecordDataHeaderLong, use 4 Byte save data length
typedef struct XLogRecordDataHeaderShort
{
uint8 id; /* XLR_BLOCK_ID_DATA_SHORT */
uint8 data_length; /* number of payload bytes */
} XLogRecordDataHeaderShort;
#define SizeOfXLogRecordDataHeaderShort (sizeof(uint8) * 2)
typedef struct XLogRecordDataHeaderLong
{
uint8 id; /* XLR_BLOCK_ID_DATA_LONG */
/* followed by uint32 data_length, unaligned */
} XLogRecordDataHeaderLong;
#define SizeOfXLogRecordDataHeaderLong (sizeof(uint8) + sizeof(uint32))边栏推荐
- 架构系列之标准Web系统的架构分层
- 图片验证,滑块验证解决
- Gerrit基本的权限管理
- 【华为联机对战】下载运行华为官方Unity示例代码,提示鉴权失败并返回错误码100114
- Grab efficiency! What has the CTO of this enterprise done right to shorten the cloud planning time by half?
- exchange
- pytest+allure定制报告
- Analysis of websocket hijacking
- [HMS core] [wallet kit] [solution] why can't Huawei wallet's client sample code run
- How to choose MySQL database storage engine? Let's take a look at the performance test
猜你喜欢

国际NFT交易所排行榜前10名

How to build a code server cloud ide platform on kubernetes

OSPF (open shortest path first) anti ring and networking application hidden dangers caused by calculation errors

如何在Kubernetes上搭建code-server 云IDE平台

从物理转 AI 、战数据库,95后程序员的职业选择

How to multiply bank revenue through customer value analysis

为何加上@Configuration注解的类会生成cglib代理?

数据湖基本架构

Stc8h Development (XIV): I2C Drive rx8025t high precision Real time clock chip

面试官:Redis主从集群切换数据丢失问题如何应对?
随机推荐
四 通用目标之make modules的执行过程分析
Basic permission management of Gerrit
宝立食品上交所上市:年营收15.78亿 市值58亿
【付费推广】常见问题合集,基础推广操作FAQ 2
[quick application] PX and VP unit conversion
从物理转 AI 、战数据库,95后程序员的职业选择
[golang] slice
[quick application] there are many words in the text component. How to solve the problem that the div style next to it will be stretched
OSPF(Open Shortest Path First開放式最短路徑優先)防環以及計算錯誤帶來的組網應用隱患
图片验证,滑块验证解决
IPFs record
【HMS Core】【FAQ】【Health Kit】集成运动健康服务过程中,遇到一些小问题,今天分享给大家(华为手表、手环+运动健康服务问题合集)
[actual combat] 1382- Yiwen owns your puppeter crawler application
2022年全球職業教育行業發展報告
js base64转图片
thymeleaf介绍与简单应用
How to choose MySQL database storage engine? Let's take a look at the performance test
如何在Kubernetes平台上搭建云IDE Theia
Postgresql源码(10)Xlog组装
一周精彩内容分享(第12期)重复