Record PCM lock information in GRD
It is located in the SGA of each instance
However, each instance only contains part of GRD, And the GRD of all instances is a complete GRD.
PCM lock has three main attributes: mode, role, and PI.
① Mode
-- S
-- X
-- Null
For S and X lock modes, we will not repeat them here
Null indicates that the corresponding memory space can be reused. Before being reused, the instance cannot access the data here.
② Role
Role is used to describe the distribution of dirty blocks between clusters.
Note: "dirty" is only used to describe whether the memory version of the data block is consistent with the disk version, and has nothing to do with transactions.
Role has two values: local and global.
(1) for local role, mode will only be s or X:
I. If mode is S, the memory version of the data block is the same as that of the disk.
Ⅱ if mode is X, the memory version of the data block is different from the disk version.
When an instance with local role and X mode sends data blocks to other instances:
I. If the recipient receives the same version as the disk, the local role of the Instance (sender) will be maintained.
II. If the recipient receives a different version from the disk, the sender and receiver's role must be converted to global.
(2) global role, mode can be S, X, or null.
Global Role means that a "dirty block" is owned by multiple instances at the same time.
If you want to flush the "dirty block" to the disk, You must contact GRD to allow the instance with the current version to complete the write operation.
However, for instances with local role, if you want to flush "Dirty blocks" to the disk, you do not need to contact GRD. This instance can complete the operation.
③ Past image
The following example shows what past image is.
Assume that a 2-node RAC cluster has a block _ A's SCN on the disk = 1
1) In node1, You need to modify block _ A and read the data from the disk into SGA. After the modification, the block _ A's SCN in the memory is 2.
2) node2 also needs to modify block _ A, and node1 will send block _ A to node2 through cache fusion, and the version with SCN = 2 will be passed,
That is, the data block of current copy. At this time, node1 will keep the data block with SCN = 2 in SGA, but it cannot be modified.
The image owned by node1 is called "past image"
Before node1 sends the current copy, the corresponding redo entry will be flushed to the redo log
3) modify the data block in node2. After modification, SCN = 3, but the disk version is still SCN = 1.
4) if a checkpoint event occurs in node1, because block _ A on node1 is a "dirty block", block _ A must be synchronized to the disk.
5) node1 will contact GRD and find that node2 has the current version of block _ A. GRD will notify node2 to write the block to the disk.
6) After node2 is written, all instances with the PI version will be notified to release their PI memory.