Summary of Oracle Transaction knowledge points

Source: Internet
Author: User

DML statement Flow
1 Get transaction Lock and ITL
2 Locking candidate rows
3 Generating Redo
4 Generate Undo
5 Generate redo record write to log buffer and change data block


Transaction commit
1 assigning SCN
2 Update the Transaction table to change the transaction slot state to 0x09
3 Recovering undo Blocks
4 Creating a commit redo record
5 Refresh the redo from log buffer
6 Releasing table and row locks



Lock
A transaction consists of 1 TX and a number of TMS, and the rollback savepoint does not release the TX lock;


ITL points to the transaction slot through the XID, which then points to the undo record, and its uba also points to the undo record;
The difference is that the transaction slot points to the start position of the undo chain, while Uba points to the last change in the transaction;




Undo chain: The undo record of the same transaction forms a one-way linked list, the newly generated insert team head;
An undo block can only be used by one transaction;





Constructing CR blocks
Session A to block DML is not committed, session B reads the block at this time will detect 1 open ITL, check the rollback segment header of the Transaction table discovery status is active, you need to construct 1 CR blocks;
Clones the current block, undoing its most recent operation by rolling back the segment header and the rollback block;
Buffer status can be viewed via x$bh.state
0 Free No valid block image
1 Xcur A current mode block, exclusive to this instance
2 Scur A current mode block, shared with other instances
3 CR A consistent read (stale) block image
4 Read buffer is reserved-a block being READ from disk
5 MREC a block in Media recovery mode
6 Irec a block in instance (crash) Recovery mode



Delay Block cleanup
The transaction slot state is only guaranteed to be changed to inactive if the block is not already in buffer, and ITL is open;
The next read updates the ITL's flag and commit SCN based on the transaction slot information, as well as the release of row Locks and FSC (free space credits), during which redo are generated;
There are 2 kinds of exceptions:
1 The Transaction table slot has been reused, i.e. wrap#>xid.wrap#, the CSCN of the rollback segment head is used as the upper bound SCN;
2 rollback segment deleted, updated with SCN in undo$ (ITL flag is cu--);
Http://www.laoxiong.net/about-block-delay-cleanout-and-consistent-reads.html


Fast block cleanup
The block is still in memory at the time of submission, updating its ITL commit SCN (lock flag not updated) and flag (-u--), the block involved up to 10% of the buffer cache;
If the block has been synchronized to the disk and the status is clean, this operation will allow it to dirty two times to refresh;
The next time the block is read, the ITL is closed by checking that the transaction slot is committed, and if the corresponding rollback segment is deleted, the SCN record is searched from the undo$;



Transaction recovery
1 rollback
Reverse-Scan all undo records (latest first) and apply them sequentially, and ITL updates;
2 process crash
Pmon is responsible for recovery, can be viewed through 10012 events;
3 database crash
Smon is responsible for recovery; When starting again, first restore the system rollback segment of the transaction, the other rollback segment transaction is set to dead, after the database open again scan these rollback segments and perform rollback;
X$ktuxe.ktuxecfl= ' DEAD ' can be used to query the dead transaction, the cflags=0x10 of its transaction slots;
10013 event can track transaction recovery at startup of database and 10015 rollback segment header before and after recovery of dump transaction;
10153 can prohibit the rollback of the dead transaction when the data block is started;



Implicit parameters
_offline_rollback_segments & _corruupted_rollback_segments
The specified rollback segment will not be scanned when the database is started, and its included active transactions will not be rolled back;
If the block contains open ITL pointing to the _offline rollback segment, the transaction table is accessed when the block is re-read, and if the transaction is committed, block cleanup is performed, and if active can only construct the CR block;


Reprint: http://blog.itpub.net/15480802/viewspace-1086960/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.