您好,登錄后才能下訂單哦!
Write-Ahead Logging (WAL) 是一種標準的保證數據完整性的方法。
Write-Ahead Logging (WAL) is a standard method for ensuring data integrity. A detailed description can be found in most (if not all) books about transaction processing. Briefly, WAL's central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after log records describing the changes have been flushed to permanent storage. If we follow this procedure, we do not need to flush data pages to disk on every transaction commit, because we know that in the event of a crash we will be able to recover the database using the log: any changes that have not been applied to the data pages can be redone from the log records. (This is roll-forward recovery, also known as REDO.)
注意:在PG中,在PostgreSQL中,WAL是Write Ahead log(寫前日志)的縮寫,可被用作事務日志的同義詞,還用于指與將操作寫入事務日志(WAL)相關的實現機制。
但在這里,為了區分,WAL泛指PostgreSQL中實現WAL(Write-Ahead Logging )的相關機制,是一個廣義的概念,而不是僅僅是事務日志(Write Ahead log)。
Redo Log
Redo Log通常稱為重做日志,其用途和意義:
1.Redo Log保存數據庫的所有修改歷史
2.Redo Log Files用于恢復/增量備份和PITR(Point In Time Recovery)/復制
3.在寫入數據文件前,每個數據庫的變更都會先行寫入到Redo Log File中
WAL segment file
持久化存儲設備上的Redo Log文件,在PG中每個WAL segment file大小為16MB(默認).
文件名稱規則:
WAL segment file name=timelineId+(uint32)(LSN?1)/(16M?256)+(uint32)((LSN?1)/16M)%256
XLOG Record(WAL data)
在PG中用于存儲歷史修改,可以認為是Redo log.
WAL buffer
XLOG Record緩沖區,Redo Log先寫入到緩沖區,在"合適的時候"通過WAL writer寫入到WAL segment file中.
LSN (Log Sequence Number)
XLOG record中的LSN表示該記錄寫入到事務日志中位置,大小為uint64.
在XLOG Record中,LSN是唯一的.
checkpointer
檢查點后臺進程,執行checkpoint.
Redo point
PostgreSQL在執行Crash Recover時的起始點.
checkpointer后臺進程啟動時,Redo point存儲在內存中.
在PG運行過程中,Redo point調整為指向啟動最新檢查點時在WAL segment file中XLOG Record的寫入位置.
checkpoint record
在執行checkpoint時,首先會在WAL buffer中寫入checkpoint相關的XLOG Record,里面包含有Redo point,這種類型的的XLOG Record成為checkpoint record.
pg_control
pg_control是物理文件,保存檢查點的基本信息,在數據庫恢復中使用.
可通過命令pg_controldata查看該文件的相關信息.
Write-Ahead Logging (WAL)
Separating bgwriter and checkpointer
Basics of Tuning Checkpoints
Write Ahead Logging — WAL
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。