Isolation level analysis of El

Source: Internet
Author: User


The isolation level analysis of the isolation level (isoation eve) defines the degree of isolation between transactions. Isolation level and concurrency are mutually contradictory: the higher the degree of isolation, the worse the database concurrency; the lower the degree of isolation, the better the database concurrency. The www.2cto.com ANSI/ISO SQ92 standard defines the isolation level for some database operations: uncommitted read (read uncommitted) committed read (read committed) repeatabe read (seriaizabe) serialization (seriaizabe) the isolation level can be reflected through some phenomena. These phenomena are: update loss (ost update): When the system allows two transactions to update the same data at the same time, an update loss occurs. Dirty read: dirty reads are generated when one transaction reads modifications that have not been committed by another transaction. Nonrepeatabe read: The same query is performed multiple times in the same transaction. Because of the modifications or deletions made by other commit firms, different result sets are returned each time. In this case, non-repeated read occurs. (A transaction rereads data it has previusy read and finds that another committed transaction has modified or deeted the data .) phantom read: The same query is performed multiple times in the same transaction. Because of the insert operations performed by other commit firms, different result sets are returned each time. In this case, a phantom read occurs. (A transaction reexecutes a query returning a set of rows that satisfies a search condition and finds that another committed transaction has inserted additiona rows that satisfy the condition .) the following are the Possible or impossible phenomena of the isolation level and its corresponding functions: nvidirty Read NonRepeatabe Read Phantom Read uncommitted Possible possible Read committed not Possible Repeatabe read not possible not pos Sible Possible Seriaizabe not possible rating e isolation level lead E provides read committed and seriaizabe in the SQ92 standard, while providing non-SQ92 standard read-ony. Read committed: This is the default transaction isolation level of ipve. Each statement in a transaction follows the statement-level read consistency. It is guaranteed that no dirty reads are performed, but non-repeated reads and phantom may occur. Seriaizabe: (the transaction is executed serially, with minimal concurrency) in short, seriaizabe is to make the transaction seem to be executed in sequence one by one. You can only see the changes committed by other transactions and the changes made in the event service before the start of this transaction. Ensure that no non-repeated read and Phantom will appear. The Seriaizabe isolation level provides read consistency (transaction-level read consistency) provided by read-ony, while allowing DM operations. Www.2cto.com if a transaction not committed at the beginning of the seriaizabe transaction modifies the row to be modified and committed before the end of the seriaizabe transaction, the seriaizabe transaction will not read these changes, therefore, an error occurs that cannot be serialized. (For another way: as long as there are other transactions between the beginning and the end of the seriaizabe transaction, the items to be modified in the seriaizabe transaction have been modified and submitted for modification, an error occurs .) If a serializable transaction contains data manipulation language (DML) that attempts to update any resource that may have been updated in a transaction uncommitted at the start of the serializable transaction, (and the modification was submitted later without rollback), then the DML statement fails. the returned error is ORA-08177: Cannot serialize access for this transaction. ORACE records the information of N transactions that recently performed the modification operation on the Data row in the data block to determine the start time of the transaction, whether the uncommitted transaction has modified the row to be modified by this transaction. For details, see Oracle permits a serializable transaction to modify a data row only if it can determine that prior changes to the row were made by transactions that had committed when the serializable transaction began. to make this determination efficiently, Oracle uses control information stored in the data block that indicates which rows in the block contain committed and uncommitted changes. in a sense, The block contains a recent history of transactions that affected each row in the block. the amount of history that is retained is controlled by the INITRANS parameter of create table and alter table. under some circumstances, Oracle may have insufficient history information to determine whether a row has been updated by a "too recent" transaction. this can occur when implements transactions concurrent Ly modify the same data block, or do so in a very short period. you can avoid this situation by setting higher values of INITRANS for tables that will experience into transactions updating the same blocks. doing so will enable Oracle to allocate sufficient storage in each block to record the history of recent transactions that accessed the block. www.2cto.com The INITRANS Parameter: Oracle stores c Ontrol information in each data block to manage access by concurrent transactions. therefore, if you set the transaction isolation level to serializable, you must use the alter table command to set INITRANS to at least 3. this parameter will cause Oracle to allocate sufficient storage in each block to record the history of recent transactions that accessed the block. higher values shocould be used f Or tables that will undergo into transactions updating the same blocks. read-ony: Compliance with transaction-level read consistency, only the changes committed by other transactions before the start of the transaction can be seen. DM operations cannot be performed in the competent service. Read ony is a subset of seriaizabe. They both avoid non-repeated reading and phantom. The difference is that read-only is used in read ony, while DM can be used in seriaizabe. Export with CONSISTENT = Y sets the difference and connection between the transaction to read-ony. read committed and seriaizabe: transaction 1 starts before transaction 2 and remains uncommitted. Transaction 2 wants to modify the row being modified by transaction 1. Transaction 2 waits. If transaction 1 is rolled back, transaction 2 (whether in the read committed or seriaizabe mode) performs the modifications it wants. If transaction 1 is committed, when transaction 2 is in the read committed mode, make the changes it wants to make. When transaction 2 is in the seriaizabe mode, the system fails and reports the error "Cannot seriaize access ", because transaction 2 cannot see the modifications committed by transaction 1, and transaction 2 wants to make modifications based on transaction 1's modifications. That is, seriaizabe does not allow transaction nesting. For details, see www.2cto.com Both read committed and serializable transactions use row-level locking, and both will wait if they try to change a row updated by an uncommitted concurrent transaction. the second transaction that tries to update a given row waits for the other transaction to commit or roll back and release its lock. if that other transaction rolls back, the waiting transa Ction (regardless of its isolation mode) can proceed to change the previusly locked row, as if the other transaction had not existed. however, if the other (blocking) transaction commits and releases its locks, a read committed transaction proceeds with its intended update. A serializable transaction, however, fails with the error "Cannot serialize access", because the other transaction has commi Tted a change that was made since the serializable transaction began. read committed and seriaizabe can be used on the ORACE Parallel Server. Set transaction read write: read write and read committed should be the same. In terms of reading, they all avoid dirty reads, but they cannot achieve repeated reads. Although there is no document indicating that read write is consistent with read committed in terms of writing, it is clear that it will apply an exclusive lock during writing to avoid loss of updates. In the process of locking, if the resource to be locked cannot be locked, wait instead of giving up. This is consistent with read committed. Statement-level read consistency objective E ensures statement-level read consistency. That is, the dataset processed by a statement is a dataset at a single time point, which is the start time of the statement. A statement cannot see the modifications submitted after it starts execution. For a DM statement, you cannot see any modifications made by yourself. That is, the DM statement sees that it starts to execute existing data. Transaction-level read consistency: www.2cto.com transaction-level read consistency ensures Repeatable read and does not show phantom. SET the isolation level of a transaction set transaction isolation level read committed; set transaction isolation level serializable; set transaction read only; SET the isolation level of the added session ater session set ISOLATION_LEVE SERIALIZABLE; ater session set ISOLATION_LEVE read committed; Choice of Isolation Level Application designers and developers shold choose an isolation level based on application performance and consistency needs as well as application coding requirements. for environments with concurrent users rapidly submitting transactions, designers must assess transaction performance requirements in terms of the expected transaction arrival rate and response time demands. frequently, for high-performance environments, the choice of isolation levels involves a trade-off between consistency and concurrency. read Committed Isolation For billing applications, read committed is the most appropriate isolation level. read committed isolation can provide considerably more concurrency with a somewhat increased risk of inconsistent results due to phantoms and non-repeatable reads for some transactions. when high-performance environments with high transaction arrival rates require more throughput and faster response times than can be achieved with serializable isolation. other environments that supports users with a very low transaction arrival rate also face very low risk of incorrect results due to phantoms and nonrepeatable reads. read committed isolation is suitable for both of these environments. two scenarios: (1) higher throughput and response time are required in a computing environment with a large transaction volume and high performance; (2) fewer transactions, in addition, the probability of phantom and non-repeated reading is lower than that of www.2cto.com Oracle read committed isolation provides transaction set consistency for every query. that is, every query sees data in a consistent state. therefore, read committed isolation will suffice for processing applications that might require a higher degree of isolation if run on other database management systems that do not use multiversion concurrency control. read committed isolation mode does not require application logic to trap the "Cannot serialize access" error and loop back to restart a transaction. in most applications, few transactions have a functional need to issue the same query twice, so for each applications protection against phantoms and non-repeatable reads is not important. therefore publish developers choose read committed to avoid the need to write such error checking and retry code in each transaction. www.2cto.com Serializable Isolation Oracle's serializable isolation is suitable for environments where there is a relatively low chance that two concurrent transactions will modify the same rows and the long-running transactions are primarily read-only. it is most suitable for environments with large databases and short transactions that update only a few rows. (1) suitable for situations where two transactions modify the same record at the same time (2) long transactions are read-only (3) large Databases and each short transaction only modifies few records Serializable isolation mode provides somewhat more consistency by protecting against phantoms and nonrepeatable reads and can be important where a read/write transaction executes a query more once. www.2cto.com Unlike other implementations of serializable isolation, which lock blocks for read as well as write, Oracle provides nonblocking queries and the fine granularity of row-level locking, both of which reduce write/write contention. for applications that experience mostly read/write contention, Oracle serializable isolation can provide significantly more throughput than other systems. therefore, some applications might be suitable for serializable isolation on Oracle but not on other systems. all queries in an Oracle serializable transaction see the database as of a single point in time, so this isolation level is suitable where multiple consistent queries must be issued in a read/write transaction. A report-writing application that generates summary data and stores it in the database might use serializable mode because it provides the consistency that a read only transaction provides, but also allows INSERT, UPDATE, and DELETE. author juji1010

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.