Oracle Undo Complexity--oracle Core technology reading notes four

Source: Internet
Author: User

I. Overview

Undo saves the old data. For example, if you modify a record to modify the A-column ABC to Def, then undo holds ABC. There are two purposes: 1. If your transaction is not committed, but the column A has been modified, then someone reading this data, you should not be able to see the content of your modified Def, you should only see the ABC, this time need to read Undo, to get to ABC. 2. If your transaction subsequently fails, you need to return the column A from the modified value def to the previous value ABC,ABC also from Undo. This article briefly describes how read consistency (that is, the uncommitted content that others cannot read to you) is implemented with rollback (transaction failure, rollback modification record).


Two. Read consistency

If session 1 9:00 opens a transaction, 9:02 session 2 modifies a data modified by a to B, then 9:03 session 2 then changes the same data from B to C, and conversation 2 has not yet been submitted. Session 1 9:04 Read this data, you should read a, but this data in the cache has been modified to C, then how to get a. Oracle does this, finds this data in the cache, finds that the data has been modified by another session, and the other session has not yet been submitted, viewing the modification time is 9:03 points, which is later than 9:00 of my session opening time, and is found in the data block's transaction slot Another session that modifies the corresponding undo record, this time reads the undo block, and if undo has been flushed out to disk, it needs to be re-read from disk. This time to find is 9:03 to modify the corresponding undo block, found the old data is B, if the undo record is 9:00, we do not need to look forward, but we found that 9:0 3, we also need to find out if there is undo in front of this undo (itself the undo record will record the address of the previous undo record), we can find the undo record 9:02. And then we find that there is no, so 9:02 the old data in the undo record is the data we are looking for. It sounds so round, give a picture:

three. rollback

Rollback is that the transaction has failed and we need to roll back all the changes made by this firm. When it comes to consistency, our main concern is to find a single block of data, and then find a pointer linked list of all undo records for this block. Start with the block and look backwards until you locate an old enough undo data. So the rollback is actually similar, the rollback is about the history of the transaction, we need all the undo records in the transaction in reverse order the list of pointers, from the last modification began to fall back to the first modification of the transaction.

Rollback and read consistency look similar, there is an important difference, read consistency, we are in memory to generate a copy of the data block, the application of the undo record to the copy block, once the relevant operation, get the old data, will quickly discard the block copy, because we are to get old data, It's not really about changing the data. Rollback is different, rollback is to get the current real data block, and apply the undo record to restore.

1. The rollback operation is the current block of data, and undo is applied to the current block, and the final modification is persisted to disk. And read consistency is not required.

2. The rollback operation is the current data block, so when we change it (rollback is the change), will generate redo (redo), as to whether to generate undo this does not validate.

3. The rollback operation may require reading the undo data from the disk as well as read consistency, and it may be necessary to read the modified data from disk, since the modified data will need to be re-fetched from disk and back to the old value if it has been flushed out to disk. If the transaction is long and the last transaction fails, the cost is very large, and the time to roll back will be about the same as the normal transaction, or even more.

Oracle Undo Complexity--oracle Core technology reading notes four

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.