当前位置:网站首页>Oracle checkpoint queue - Analysis of the principle of instance crash recovery
Oracle checkpoint queue - Analysis of the principle of instance crash recovery
2022-07-05 21:42:00 【Ruthless white】
Checkpoint queue – Analysis of the principle of instance crash recovery
What is checkpoint queue ?
The checkpoint queue connects dirty blocks , Connect the dirty data blocks back in sequence according to the first time , Form a line .
What is the role of checkpoints ?
A checkpoint is just a database event , The fundamental significance of its existence is to reduce the crash recovery time ,Oracle8i In the past, there was no checkpoint queue , When the database goes down or shuts down abnormally (shutdown abort) Starting the database again will be based on all redo log The log restores the submitted data , It takes a long time , After the checkpoint queue appears, you only need to find the first dirty fast corresponding redo log The address of is corresponding to the last dirty dirty fast redo log Address recovery , Reduced recovery time . Here's the picture :
First, let's know some nouns :
RBA: redo block address The address of the log , The address of the log block . If we modify a database and submit it, it will be in redo log Generate the corresponding log in .RBA It is the log address corresponding to the modified data block .
Expand : For each dirty block, there is LRBA and HRBA,LRBA Data block refers to the earliest dirty log address HRBA The recently dirty log address of the data block is also the last modified log address of the current data block . Suppose the last time is the fifth time I got dirty , It also corresponds to an address called HRBA Address .
LRBA Record the address of the first dirty data block , And the log is recorded in chronological order buffercache The course of change , That is, the dirty database behind it will be behind it, that is, all data blocks behind the checkpoint queue , Their dirty logs , All in LRBA Under the corresponding log address .
As the data block in the figure ( After the document 6 Block500) Changed to B Because the corresponding time is the earliest to be modified , So it can be understood as LRBA, So the corresponding redo log It also ranks first , And in is modified as A after , Another transaction , Although I don't know what specific changes have been made , But it's just changing to A After the transaction of , So it ranks second ,redo log Your address is only LRBA after , Then came another transaction , Change the previous to B The name of the data block of is changed to C, To control the length and performance of the checkpoint queue , If the same data block is modified again, it will not be linked to the chain again . So you can't see it on the chain , But it will be recorded in redo log in , This is the process of data block being modified and submitted .
Background process and recovery : checkpoint (CKPT)
To understand instance recovery , You need to understand the functions of a specific background process .
Every three seconds ( Or higher frequency ),CKPT The process stores data once in the control file , To record DBWn from
SGA Modified data block written to disk . This is called a “ checkpoint ”. The purpose of checkpoints is to identify online redoes
The location where the log file starts instance recovery ( This position is called “ Checkpoint location ”).
If log switching is used ,CKPT The process will also write this checkpoint information to the data file header .
The reasons for using checkpoints are as follows :
• Ensure that the modified data blocks in memory are written to disk regularly , In case of system or database failure
Data will not be lost under
• Reduce the time required for instance recovery . When recovering, you only need to deal with the online following the last checkpoint
Redo log file
• Ensure that all submitted data is written to the data file during shutdown
from CKPT The checkpoint information written by the process includes the checkpoint location 、 System change number 、 Start in the online redo log file
Recovered location 、 Information about logs and so on .
notes :CKPT The process does not write data blocks to disk , Nor write the redo block to the online redo log file .
How the checkpoint process works :
After starting the database, enter ps -ef|grep ora You will find a process ora_ckpt This process is the checkpoint process
This process has many advantages Two ways of working
Full checkpoint : When a complete checkpoint occurs ,CKPT The process will trigger DBWR, Write all dirty blocks to disk .
Incremental checkpoints : Record the earliest dirty log address of the checkpoint queue in the control file , If you find dirt too fast , Trigger DBWR, Shorten the checkpoint queue .
Complete checkpoint case :
The most classic is when closing the database ,oracle A complete checkpoint will occur ,CKPT Will trigger DBWR Write all dirty buffers to disk , In this way, the database is clean and closed .
When the database is running normally, a full checkpoint will occur only when it is shut down normally , Therefore, complete checkpointing rarely occurs during normal operation of the database , It will cause incremental checkpoints .oracle every other 3 An incremental checkpoint occurs every second .
We can use one sql To view the currently dirty data block
select CPDRT,CPLRBA_SEQ||'.'||CPLRBA_BNO||'.'||CPLRBA_BOF "Low RBA",
CPODR_SEQ||'.'||CPODR_BNO||'.'||CPODR_BOF "On disk RBA",CPODS,CPODT,CPHBT
from x$kcccp;
Execution results
SQL> select CPDRT,CPLRBA_SEQ||'.'||CPLRBA_BNO||'.'||CPLRBA_BOF "Low RBA",
CPODR_SEQ||'.'||CPODR_BNO||'.'||CPODR_BOF "On disk RBA",CPODS,CPODT,CPHBT
from x$kcccp; 2 3
CPDRT Low RBA On disk RBA CPODS CPODT CPHBT
---------- -------------------- -------------------- ---------------- -------------------- ----------
16 5.13167.0 2.34561.0 527629 06/20/2022 13:58:38 911687624
0 0.0.0 0.0.0 0 0
0 0.0.0 0.0.0 0 0
0 0.0.0 0.0.0 0 0
0 0.0.0 0.0.0 0 0
0 0.0.0 0.0.0 0 0
0 0.0.0 0.0.0 0 0
0 0.0.0 0.0.0 0 0
8 rows selected.
CPDRT Column is the number of dirty blocks in the checkpoint queue ;
CPODS The column is on disk rba Of scn ;
CPODT The column is on disk rba The timestamp ;
CPHBT The column is the heartbeat .
On disk RBA Column is an address ,on disk rba yes current The address of the last log in the log . It is the address of the last log saved in our current database ,logbuffer Many logs inside have not been written current Go inside , however logbuffer The last log written in is called on disk rba. In the current database current redolog The latest record in it rba The address is on disk rba.
If you want to brush the database to disk, you can execute
alter system flush buffer_cache;
If you query the dirty fast quantity again, it will become 0, The checkpoint queue is also empty .
Instance recovery
Instance recovery or crash recovery :
• The reason is to try to open a database , The files in the database are closing
No synchronization at
• It's automatic
• Use the information stored in the redo log group to synchronize files
• There are two different operations involved :
– Roll forward : The data file is restored to the state it was in before the instance failed .
– Back off : Changes that have been executed but not yet committed will return to the initial state .
Oracle Database 10g It will automatically recover from instance failure .DBA The operation to be performed is to start the instance normally .
The instance will load the control file , Then try to open the data file . If you find that the data file is not synchronized when it is closed ,
Then use the information contained in the redo log group to roll forward the data file to the closed state , Then return all uncommitted
Transaction processing ( Because the restored tablespace has also rolled forward ).
边栏推荐
- DBeaver同时执行多条insert into报错处理
- EL与JSTL注意事项汇总
- Simple interest mode - evil Chinese style
- @Validated basic parameter verification, grouping parameter verification and nested parameter verification
- 华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
- "Grain mall" -- Summary and induction
- uni-app 蓝牙通信
- Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
- Chapter 05_ Storage engine
- Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
猜你喜欢
Some common processing problems of structural equation model Amos software
Kingbasees v8r3 cluster maintenance case -- online addition of standby database management node
matlab绘制hsv色轮图
秋招将临 如何准备算法面试、回答算法面试题
MMAP
Wood board ISO 5660-1 heat release rate mapping test
Introduction of ArcGIS grid resampling method
力扣------经营摩天轮的最大利润
张丽俊:穿透不确定性要靠四个“不变”
Uni app Bluetooth communication
随机推荐
R language learning notes
华为快游戏调用登录接口失败,返回错误码 -1
ESP32
Objects in the list, sorted by a field
Emotional analysis of wechat chat records on Valentine's day based on Text Mining
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
使用Aspect制作全局异常处理类
Oracle HugePages没有被使用导致服务器很卡的解决方法
面试官:并发编程实战会吗?(线程控制操作详解)
总结出现2xx、3xx、4xx、5xx状态码的原因
The primary key is set after the table is created, but auto increment is not set
秋招将临 如何准备算法面试、回答算法面试题
Efficiency difference between row first and column first traversal of mat data types in opencv
QML reported an error expected token ";", expected a qualified name ID
Golang (1) | from environmental preparation to quick start
Introduction of ArcGIS grid resampling method
Advantages of robot framework
selenium 获取dom内验证码图片
Kingbasees v8r3 data security case - audit record clearing case
递归查询多级菜单数据