关于IMU的知识点,如有错误,请指正!!!
1、首先说明一下,alert log中的记录“Private Strand Flush Not Complete”是一种预期行为,不能当做异常日志来看待,可参考MOS 文档Alert Log Messages: Private Strand Flush Not Complete (Doc ID 372557.1)
2、IMU—>In Memory Undo,10g新特性,我有理解该特性是一种批量化优化,一个事务中多个DML执行,可以延迟生成UNDO块、REDO,将多次操作缓存起来批量生成,减少相关争用如latch(如构造CR块时读取UNDO块的相关latch,redo allocation latch,redo copy latch),因为减少了REDO RECORD数目所以总体REDO量也有减少
3、在commit或者flush IMU,会根据IMU pool中的IMU node修改(生成)UNDO块,生成REDO,将Private redo合并到redo buffer中写入到redo log
4、当开启IMU参数时,ORACLE会判断是否使用IMU,RAC环境中不支持IMU,事务较大时不使用IMU,无法获取private strand时不使有IMU。
疑问1
因为延迟了UNDO,REDO的生成,DML只修改了DATA BLOCK,是否会有赃款先于UNDO,REDO前落盘的情况,如checkpoint,或flush buffer cache时是否会做flush IMU,如果不做,那么可能只有DATA BLOCK赃块落盘,如果这时实例CRASH了,没有UNDO,REDO如果恢复一致性?
测试验证
---创建测试表
SQL> create table dbmt.test_imu(id number,c varchar2(1000));
Table created.
SQL> insert into dbmt.test_imu values (1,'ABCDEF');
1 row created.
SQL> commit;
Commit complete.
---找到数据所在数据块,方便后面hexdump查看
SQL> @rowid_scan dbmt.test_imu 1=1
RFILE# BLOCK# ROW# DBA DUMP_COMMAND
---------- ---------- ---------- ---------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4 3887 0 0x1000F2F alter system dump datafile 4 block 3887; -- @dump 4 3887 .
SQL>
SQL>
SQL> alter system flush buffer_cache;
System altered.
---hexdump验证数据已落盘
[oracle@db1 ~]$ hexdump -C -s $( expr 8192 \* 3895) -n 8192 /home/oracle/users01.dbf |grep -i ABCDEF
01e6fff0 01 02 02 c1 02 06 41 42 43 44 45 46 01 06 11 cc |......ABCDEF....| <<<<
--查看INU统计数据当前值
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ------------------------------------ ---------- ---------- ----------
374 IMU commits 128 1 1914489094<<<
375 IMU Flushes 128 8 2099506212<<<
376 IMU contention 128 0 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 10408 244193920<<<
385 IMU Redo allocation size 128 11956 3945654623<<<
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
---更新一条数据
SQL> update dbmt.test_imu set c='abcdef';
1 row updated.
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ----------------------------------- ---------- ---------- ----------
374 IMU commits 128 1 1914489094<<<
375 IMU Flushes 128 8 2099506212<<<
376 IMU contention 128 0 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 10408 244193920<<<
385 IMU Redo allocation size 128 11956 3945654623<<<
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
SQL>
---session 2
SQL> alter system flush buffer_cache;
System altered.
SQL>
----flush buffer_cache 并没有触发IMU Flushes
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ------------------------------------- ---------- ---------- ----------
374 IMU commits 128 1 1914489094<<<
375 IMU Flushes 128 8 2099506212<<<
376 IMU contention 128 0 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 10408 244193920
385 IMU Redo allocation size 128 11956 3945654623
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
----flush buffer_cache 赃块并未落盘
[oracle@db1 ~]$ hexdump -C -s $( expr 8192 \* 3895) -n 8192 /home/oracle/users01.dbf |grep -i ABCDEF
01e6fff0 01 02 02 c1 02 06 41 42 43 44 45 46 01 06 11 cc |......ABCDEF....|<<<<<不是更新后的abcdef
[oracle@db1 ~]$
----flush buffer_cache 赃块并未落盘
SQL> select FILE#,BLOCK#,STATUS from v$bh where file#=4 and block#=3895;
FILE# BLOCK# STATUS
---------- ---------- ----------
4 3895 free
4 3895 free
4 3895 xcur <<<<<
SQL> commit;
Commit complete.
----commit触发IMU Flushes
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ------------------------------------- ---------- ---------- ----------
374 IMU commits 128 1 1914489094
375 IMU Flushes 128 9 2099506212<<<
376 IMU contention 128 1 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 11792 244193920
385 IMU Redo allocation size 128 13272 3945654623
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
----再次flush buffer_cache 赃块已落盘
SQL> alter system flush buffer_cache;
System altered.
SQL> select FILE#,BLOCK#,STATUS from v$bh where file#=4 and block#=3895;
FILE# BLOCK# STATUS
---------- ---------- ----------
4 3895 free
4 3895 free
4 3895 free
SQL>
oracle@db1 ~]$ hexdump -C -s $( expr 8192 \* 3895) -n 8192 /home/oracle/users01.dbf |grep -i ABCDEF
01e6fff0 02 02 02 c1 02 06 61 62 63 64 65 66 01 06 52 cc |......abcdef..R.| <<<<
[oracle@db1 ~]$
SQL> update dbmt.test_imu set c='abcdef';
1 row updated.
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
374 IMU commits 128 1 1914489094
375 IMU Flushes 128 10 2099506212
376 IMU contention 128 2 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 13464 244193920
385 IMU Redo allocation size 128 14588 3945654623
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
SQL> alter system checkpoint;
System altered.
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ---------------------------------------------------------------- ---------- ---------- ----------
374 IMU commits 128 1 1914489094
375 IMU Flushes 128 11 2099506212
376 IMU contention 128 3 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 13464 244193920
385 IMU Redo allocation size 128 14588 3945654623
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
---test checkpoint
SQL> update dbmt.test_imu set c='abcdef';
1 row updated.
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ------------------------------------ ---------- ---------- ----------
374 IMU commits 128 1 1914489094
375 IMU Flushes 128 10 2099506212<<<<
376 IMU contention 128 2 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 13464 244193920
385 IMU Redo allocation size 128 14588 3945654623
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
SQL> alter system checkpoint;
System altered.
---checkpoint会发生IMU Flushes
SQL> select * from v$sysstat where name like '%IMU%';
STATISTIC# NAME CLASS VALUE STAT_ID
---------- ------------------------------------------------ ---------- ----------
374 IMU commits 128 1 1914489094
375 IMU Flushes 128 11 2099506212<<<<
376 IMU contention 128 3 2909373607
377 IMU recursive-transaction flush 128 0 2591100633
378 IMU undo retention flush 128 0 2087226422
379 IMU ktichg flush 128 1 1206609541
380 IMU bind flushes 128 0 2756376339
381 IMU mbu flush 128 0 3723686946
382 IMU pool not allocated 128 0 659017805
383 IMU CR rollbacks 128 0 2225124543
384 IMU undo allocation size 128 13464 244193920
385 IMU Redo allocation size 128 14588 3945654623
386 IMU- failed to get a private strand 128 0 2412863545
13 rows selected.
SQL>
测试结论:
1、当使用IMU时,flush buffer 不会触发IMU Flushes,还没有IMU Flushes的脏块是不会落盘的
2、checkpoint时会IMU Flushes
今天先测后这,后续补充




