QUOTE:
原帖由
shiri512003 于 2008-3-31 10:10 发表
commit/rollback可能会要伴随着对数据文件的更改,所以会有dbwr,dbwr在写回数据文件前,必须redo file写完成。
"Before writing a batch of database blocks, DBWn finds the highest high redo block address that needs to be synced before the batch can be written. DBWn then takes the redo allocation latch to ensure that the required redo block address has already been written by LGWR, and if not, it posts LGWR and sleeps on a log file sync wait."
commit/rollback的确会有数据更改但是并不时每次都需要dbwr被唤醒呀
DBWn defers writing to the data files until one of the following events occurs:
1. Incremental or normal checkpoint。
2. The number of dirty buffers reaches a threshold value。
3. A process scans a specified number of blocks when scanning for free buffers and cannot find any。
4. Timeout occurs 。
5. A ping request in Real Application Clusters (RAC) environment。
6. Placing a normal or temporary tablespace offline。
7. Placing a tablespace in read-only mode。
8. Dropping or truncating a table。
9. ALTER TABLESPACE tablespace name BEGIN BACKUP。
如果是因为checkpoint来触发dbwr那么CKPT的条件是:
1.发生日志组切换的时候
2.符合LOG_CHECKPOINT_TIMEOUT,LOG_CHECKPOINT_INTERVAL,fast_start_io_target,fast_start_mttr_target参数设置的时候
3.运行ALTER SYSTEM SWITCH LOGFILE的时候
4.运行ALTER SYSTEM CHECKPOINT的时候 (完全检查点)
5.运行alter tablespace XXX begin backup,end backup的时候
6.运行alter tablespace ,datafile offline的时候;
7.shutdown immediate (完全检查点)
也没有和commit/rollback相关的地方呀??
再有正像文档上说的,DBWn then takes the redo allocation latch to ensure that the required redo block address has already been written by LGWR, and if not, it posts LGWR and sleeps on a log file sync wait." 每次DBWn被触发去写脏数据,都需要确保LGWR已经吧脏数据写入redo,加入没有写入就会唤醒LGWR去写。这是满足LGWR被触发条件的:
1. When a transaction commits
2. When the redo log buffer becomes one-third full
3. When there is more than a megabyte of changed records in the redo log buffer.
4. When timeout occurs(every 3 seconds)
5. check point
6. Before the DBWn writes modified blocks in the database buffer cache to the data files.
我理解的文档的意思是,有两种方式都会有log file sync等待:
1.user commit/rollback 导致log file sync .
2.dbwr 启动,需要唤醒lgwr来写数据 导致 log file sync.
但无论那种方式,每次log file sync都会和lgwr被触发成对出现。而lgwr每次唤醒去写redo log都应该有一个log file parallel write的等待。那么为什么这两个等待次数不相同呢?就算lgwr被其他方式所触发去写日至(1M,1/3)这两种情况下,没有dbwr,没有user commit,那么按照上面的理解应该没有log file sync的等待,只应该有log file parallel write的等待。也就是说log file parallel write的次数应该大于> log file sync的次数。
但是我经常可以看到log file sync > log file parallel write~
这是为什么?~
谢谢~