设为首页 加入收藏

TOP

PostgreSQL启动过程中的那些事七:初始化共享内存和信号二:shmem中初始化xlog(一)
2014-11-24 00:59:50 来源: 作者: 【 】 浏览:36
Tags:PostgreSQL 启动 过程 那些 初始 共享 内存 信号 shmem xlog

pg初始化完shmem,给其加上索引"ShmemIndex"后,接着就在shmem里初始化xlog。

1先上个图,看一下函数调用过程梗概,中间略过部分细节

\

初始化xlog方法调用流程图

2初始化xlog相关结构

话说main()->…->PostmasterMain()->…->reset_shared() ->CreateSharedMemoryAndSemaphores()>…->XLOGSHmemInit(),初始化控制文件data/global/pg_control相关数据结构及事务日志xlog相关数据结构,相关结构定义在下面。

typedef struct ControlFileData

{

/*

* Unique system identifier --- to ensure wematch up xlog files with the

* installation that produced them.

*/

uint64 system_identifier;

/*

* Version identifier information. Keep these fields at the same offset,

* especially pg_control_version; they won't bereal useful if they move

* around. (Forhistorical reasons they must be 8 bytes into the file

* rather than immediately at the front.)

*

* pg_control_version identifies the format ofpg_control itself.

* catalog_version_no identifies the format ofthe system catalogs.

*

* There are additional version identifiers inindividual files; for

* example, WAL logs contain per-page magic numbersthat can serve as

* version cues for the WAL log.

*/

uint32 pg_control_version; /* PG_CONTROL_VERSION */

uint32 catalog_version_no; /* see catversion.h */

/*

* System status data

*/

DBState state; /*see enum above */

pg_time_t time; /*time stamp of last pg_control update */

XLogRecPtr checkPoint; /*last check point record ptr */

XLogRecPtr prevCheckPoint; /* previous check point recordptr */

CheckPoint checkPointCopy; /* copy of last check pointrecord */

/*

* These two values determine the minimum pointwe must recover up to

* before starting up:

*

* minRecoveryPoint is updated to the latestreplayed LSN whenever we

* flush a data change during archive recovery.That guards against

* starting archive recovery, aborting it, andrestarting with an earlier

* stop location. If we've already flushed datachanges from WAL record X

* to disk, we mustn't start up until we reachX again. Zero when not

* doing archive recovery.

*

* backupStartPoint is the redo pointer of thebackup start checkpoint, if

* we are recovering from an online backup andhaven't reached the end of

* backup yet. It is reset to zero when the endof backup is reached, and

* we mustn't start up before that. A booleanwould suffice otherwise, but

* we use the redo pointer as a cross-checkwhen we see an end-of-backup

* record, to make sure the end-of-backuprecord corresponds the base

* backup we're recovering from.

*/

XLogRecPtr minRecoveryPoint;

XLogRecPtr backupStartPoint;

/*

* Parameter settings that determine if the WALcan be used for archival

* or hot standby.

*/

int wal_level;

int MaxConnections;

int max_prepared_xacts;

int max_locks_per_xact;

/*

* This data is used to check for hardware-architecturecompatibility of

* the database and the backendexecutable. We need not check endia

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇YII数据库查询 下一篇PostgreSQL启动过程中的那些事七..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: