[20201231]RAC buffer states: XCUR, SCUR, PI,CR.txt

lfree發表於2021-01-01

[20201231]RAC buffer states: XCUR, SCUR, PI,CR.txt

--//別人問及rac buffer狀態PI,按照文件介紹就是past image.

■ Note If you have SYS privileges you can run the following query to see how many blocks you have in what
state: select state, count(*) from x$bh group by state; The commonest states are:  0—free, 1—XCUR
(exclusive current), 2—SCUR (shared current), 3—CR (available only for consistent read), 8—PI (past image). This
isn't a nice thing to do to your buffer cache, so resist the temptation to do it on a busy production system with a
large cache.

--//RAC涉及快取融合以及資源掌控方面的問題,搞的比單例項的資料庫要複雜N多。
--//不過我找到一篇blog。http://www.dbi-services.com/index.php/blog/entry/rac-buffer-states-xcur-scur-pi-ci
--//注:後面的ci我估計作者筆誤,應該不是CI而是CR。我在自己的環境下重複測試,說明問題。

1.環境:
SYS@192.168.90.18:1521/fyhis/fyhis1> @ ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

$ cat bhy.sql
SELECT inst_id
        ,class#
        ,status
        ,lock_element_addr
        ,dirty
        ,temp
        ,ping
        ,stale
        ,direct
        ,new
    FROM gv$bh
   WHERE     objd = (SELECT data_object_id
                       FROM dba_objects
                      WHERE owner = 'SCOTT' AND object_name = 'DEPT')
         AND status != 'free'
ORDER BY inst_id;

$ cat bh.sql
set echo off
--------------------------------------------------------------------------------
-- @name: bh
-- @author: dion cho
-- @note: show block header
-- @usage: @bh f# b# state
--------------------------------------------------------------------------------
col object_name format a20
col state format a10

select
b.inst_id,
b.hladdr,
  b.dbarfil,
  b.dbablk,
  b.class,
  decode(b.class,1,'data block',2,'sort block',3,'save undo block', 4,
  'segment header',5,'save undo header',6,'free list',7,'extent map',
  8,'1st level bmb',9,'2nd level bmb',10,'3rd level bmb', 11,'bitmap block',
  12,'bitmap index block',13,'file header block',14,'unused',
  15,'system undo header',16,'system undo block', 17,'undo header',
  18,'undo block') class_type,
  decode(state,0,'free',1,'xcur',2,'scur',3,'cr', 4,'read',5,'mrec',6,'irec',7,'write',8,'pi', 9,'memory',10,'mwrite',11,'donated') as state,
  b.tch,
  cr_scn_bas,
  cr_scn_wrp,
  cr_uba_fil,
  cr_uba_blk,
  cr_uba_seq,
  ba,
  b.LE_ADDR,
  (select object_name from dba_objects where data_object_id = b.obj) as object_name
from x$bh b
where
  dbarfil = &1 and
  dbablk = &2
;
--//增加LE_ADDR,inst_id欄位,我發現在單例項上LE_ADDR輸出是00.

SYS@192.168.90.18:1521/fyhis/fyhis1> select rowid from scott.dept where deptno=10;
ROWID
------------------
AAAVRCAAEAAAACHAAA

SYS@192.168.90.18:1521/fyhis/fyhis1> @ rowid AAAVRCAAEAAAACHAAA
    OBJECT       FILE      BLOCK        ROW ROWID_DBA            DBA                  TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
     87106          4        135          0  0x1000087           4,135                alter system dump datafile 4 block 135 ;

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
no rows selected
--//沒有輸出正常,因為並沒有訪問對應的資料塊。

2.測試:
--//session 1:
SYS@192.168.90.18:1521/fyhis/fyhis1> select * from scott.dept where rowid='AAAVRCAAEAAAACHAAA';
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135

   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         scur                1          0          0          0          0          0 0000000461890000 0000000117F2B4D8 DEPT

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bhy 4 135
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 scur       0000000117F2B4D8 N N N N N N
--//僅僅出現在1個資料庫例項上。
--//注意state=scur,而不是像單例項出現的是state=xcur.也許這個是RAC的特性.

--//session 2,執行呢?
SYS@192.168.90.18:1521/fyhis/fyhis2> select * from scott.dept where rowid='AAAVRCAAEAAAACHAAA';

    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         2 00000004E239D750          4        135          1 data block         scur                2          0          0          0          0          0 000000037465A000 0000000223FB8D68 DEPT

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bhy 4 135
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 scur       0000000117F2B4D8 N N N N N N
         2          1 scur       0000000223FB8D68 N N N N N N
--//沒有修改塊,兩邊都是共享的。state=scur.

3.繼續測試:
--//session 1,做一個修改,注我的測試與原連結不同,我沒有重新整理資料快取:
SYS@192.168.90.18:1521/fyhis/fyhis1> select * from scott.dept where rowid='AAAVRCAAEAAAACHAAA' for update;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         xcur                2          0          0          0          0          0 00000000A076A000 0000000117F2B4D8 DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  2 3703090073          7          0          0          0 0000000461890000 00               DEPT

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bhy
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 xcur       0000000117F2B4D8 Y N N N N N
         1          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N

--//session 2:
SYS@192.168.90.18:1521/fyhis/fyhis2> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090072          7          0          0          0 000000037465A000 00               DEPT

--//看看在兩個例項上執行bh.sql指令碼的輸出。
--//例項2的STATE從scur->CR,而CR_SCN_BAS從0變成了3703090072。
--//例項1的STATE從scur->CR,而CR_SCN_BAS從0變成了3703090073。也就是先要修改例項2的狀態在修改例項1的狀態們(從scn資訊可以看出來)。
--//例項1上生成新塊state=xcur.
--//在session 2繼續執行:

SYS@192.168.90.18:1521/fyhis/fyhis2> select * from scott.dept where rowid='AAAVRCAAEAAAACHAAA';
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090708          7          0          0          0 0000000384620000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090072          7          0          0          0 000000037465A000 00               DEPT
--//增加1行,state=cr.

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bhy
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 xcur       0000000117F2B4D8 Y N N N N N
         1          1 cr         00               N N N N N N
         1          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N

--//session 1:
SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         cr                  0 3703090708          7          3       4278      36326 0000000190F96000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         xcur                2          0          0          0          0          0 00000000A076A000 0000000117F2B4D8 DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  2 3703090073          7          0          0          0 0000000461890000 00               DEPT
--//你可以發現現在例項1上構造出CR_SCN_BAS=3703090708,然後在傳輸到例項2上。

--//session 2,注意修改發生在例項1:
SYS@192.168.90.18:1521/fyhis/fyhis2> alter system checkpoint;
System altered.

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bhy
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 xcur       0000000117F2B4D8 N N N N N N
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
         1          1 cr         00               N N N N N N
         1          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
--//dirty標識清除。發生在例項1.

4.測試STATE=PI的狀態如何出現:
--//session 1:
SYS@192.168.90.18:1521/fyhis/fyhis1> commit ;
Commit complete.

SYS@192.168.90.18:1521/fyhis/fyhis1> alter system checkpoint;
System altered.

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bhy
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 xcur       0000000117F2B4D8 Y N N N N N
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
         1          1 cr         00               N N N N N N
         1          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
--//變成了髒塊.
--//session 2:
SYS@192.168.90.18:1521/fyhis/fyhis2> select * from scott.dept where rowid='AAAVRCAAEAAAACHAAA' for update;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bhy
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 cr         00               N N N N N N
         1          1 cr         00               N N N N N N
         1          1 pi         0000000117F2B4D8 Y N N N N N
         2          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 xcur       0000000223FB8D68 Y N N N N N
7 rows selected.
--//注意看dirty標識,兩個依舊標識為Y。例項1原來的state 從xcur->pi,也就是post image.

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         2 00000004E239D750          4        135          1 data block         xcur                1          0          0          0          0          0 00000003C8108000 0000000223FB8D68 DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000003B5A72000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090708          7          0          0          0 0000000384620000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090072          7          0          0          0 000000037465A000 00               DEPT

--//session 1檢視:
SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         cr                  0 3703090708          7          3       4278      36326 0000000190F96000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         pi                  2          0          0          0          0          0 00000000A076A000 0000000117F2B4D8 DEPT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
         1 00000004E22F9FD8          4        135          1 data block         cr                  2 3703090073          7          0          0          0 0000000461890000 00               DEPT
--//例項1的原來state=xcur  變成了 state = pi.

--//session 2:
SYS@192.168.90.18:1521/fyhis/fyhis2> alter system checkpoint;
System altered.

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bhy
   INST_ID     CLASS# STATUS     LOCK_ELEMENT_ADD D T P S D N
---------- ---------- ---------- ---------------- - - - - - -
         1          1 cr         00               N N N N N N
         1          1 cr         00               N N N N N N
         1          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 cr         00               N N N N N N
         2          1 xcur       0000000223FB8D68 N N N N N N
7 rows selected.
--//state=pi標識清除,變成了cr,而且lock_element_addr=00.並且標識dirty變成Y->N(2個例項)

--//session 1:
SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         cr                  0 3703090708          7          3       4278      36326 0000000190F96000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000000A076A000 00               DEPT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         1 00000004E22F9FD8          4        135          1 data block         cr                  2 3703090073          7          0          0          0 0000000461890000 00               DEPT
--//特別注意下劃線的CR_SCN_BAS=3703092337.原來是0. 很奇怪的是TCH從2變成了1,LE_ADDR=00.

--//session 2:
SYS@192.168.90.18:1521/fyhis/fyhis2> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         2 00000004E239D750          4        135          1 data block         xcur                1          0          0          0          0          0 00000003C8108000 0000000223FB8D68 DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000003B5A72000 00               DEPT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090708          7          0          0          0 0000000384620000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090072          7          0          0          0 000000037465A000 00               DEPT
--//注意看下劃線以及CR_SCN_BAS列的變化。你可以猜測大概操作流程,先從例項1傳輸或者複製過來,然後在修改。
--//從例項1 CR_SCN_BAS=0 變成 3703092337,就可以看出來。

5.繼續測試:
--//從例項2讀取特定scn的情況。
--//7,3703090073 = scn(10): 33767861145 = scn(16): 0x7dcb8ab99
--//session 2:
SYS@192.168.90.18:1521/fyhis/fyhis2> commit ;
Commit complete.

SYS@192.168.90.18:1521/fyhis/fyhis2> select * from scott.dept as of scn 33767861145 where rowid='AAAVRCAAEAAAACHAAA' ;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         2 00000004E239D750          4        135          1 data block         xcur                1          0          0          0          0          0 00000003C8108000 0000000223FB8D68 DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000003B5A72000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  2 3703090708          7          0          0          0 0000000384620000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090072          7          0          0          0 000000037465A000 00               DEPT

--//session 1:
SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         cr                  0 3703090708          7          3       4278      36326 0000000190F96000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000000A076A000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  2 3703090073          7          0          0          0 0000000461890000 00               DEPT
--//沒有變化,甚至tch值。視乎這樣的查詢僅僅透過例項1傳輸過來。
--//session 1,重複上面的查詢:
SYS@192.168.90.18:1521/fyhis/fyhis1> select * from scott.dept as of scn 33767861145 where rowid='AAAVRCAAEAAAACHAAA' ;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         cr                  0 3703090708          7          3       4278      36326 0000000190F96000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000000A076A000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  3 3703090073          7          0          0          0 0000000461890000 00               DEPT
--//可以發現TCH從2 -> 3.

--//session 2,改變scn看看呢?
SYS@192.168.90.18:1521/fyhis/fyhis2> select * from scott.dept as of scn 33767861146 where rowid='AAAVRCAAEAAAACHAAA' ;
    DEPTNO DNAME          LOC
---------- -------------- -------------
        10 ACCOUNTING     NEW YORK
--//33767861146    = scn_wrap,scn_base(10): 7,3703090074 = scn_wrap,scn_base(16): 0x7,0xdcb8ab9a

SYS@192.168.90.18:1521/fyhis/fyhis2> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         2 00000004E239D750          4        135          1 data block         xcur                1          0          0          0          0          0 00000003C8108000 0000000223FB8D68 DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000003B5A72000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  3 3703090708          7          0          0          0 0000000384620000 00               DEPT
         2 00000004E239D750          4        135          1 data block         cr                  1 3703090072          7          0          0          0 000000037465A000 00               DEPT
--//如果你仔細觀察就能發現CR_SCN_BAS=3703090708的TCH從2->3.也就是構造從當前例項CR_SCN_BAS=3703090708 反向操作會 scn= 7,3703090074.
--//session 1:

SYS@192.168.90.18:1521/fyhis/fyhis1> @ bh 4 135
   INST_ID HLADDR              DBARFIL     DBABLK      CLASS CLASS_TYPE         STATE             TCH CR_SCN_BAS CR_SCN_WRP CR_UBA_FIL CR_UBA_BLK CR_UBA_SEQ BA               LE_ADDR          OBJECT_NAME
---------- ---------------- ---------- ---------- ---------- ------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------------- ---------------- --------------------
         1 00000004E22F9FD8          4        135          1 data block         cr                  0 3703090708          7          3       4278      36326 0000000190F96000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  1 3703092337          7          0          0          0 00000000A076A000 00               DEPT
         1 00000004E22F9FD8          4        135          1 data block         cr                  3 3703090073          7          0          0          0 0000000461890000 00               DEPT

6.總結:
--//至於為什麼出現PI,按照文件介紹節省recovery的恢復時間,一些細節操作我的分析能力。
--//測試還是有點亂....
--//http://www.dbi-services.com/index.php/blog/entry/rac-buffer-states-xcur-scur-pi-ci
Here are the states we have seen here:

XCUR: current version of the block - holding an exclusive lock for it
SCUR: current version of the block that can be share because no modification were done
CR: only valid for consistent read, after applying the necessary undo to get it back to requried SCN
PI: past image of a modified current block, kept until the latest version is checkpointed

and the other possible states:

FREE: The buffer is not currently in use.
READ: when the block is being read from disk
MREC: when the block is being recovered for media recovery
IREC: when the block is being recovered for crash recovery

--//實際上rac並非是什麼好東西,處理不好比單例項要慢,特別是原來單例項就存在效能問題的情況下,rac環境可能放大這樣的效果.
--//而且從上面測試也可以看出幾點:
--//1.事務應該還是儘可能的快速提交.
--//2.內聯的網路傳輸能力要儘量的塊.儘可能進行業務分割.相同的業務在1個例項處理.我還見過內聯網路使用hub的情況.
--//  這種網路裝置一般就是100M,全雙工也就是200M,最大傳輸能力就是20M/秒.這樣如果內聯流量很大,出現問題的可能性很大.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2747003/,如需轉載,請註明出處,否則將追究法律責任。

相關文章