blog




  • Essay / SQL Transactions

    The isolation level controls the extent to which a given transaction is exposed to the actions of other transactions running concurrently. By choosing one of four possible isolation level settings, a user can achieve greater concurrency at the cost of increased exposure of the transaction to uncommitted changes from other transactions. The effect of these levels is summarized. The highest degree of isolation from the effects of other transactions is achieved by setting the isolation level of a transaction T to SERIALIZABLE. This isolation level ensures that T only reads changes made by committed transactions, that no values ​​read or written by T are modified by another transaction until T is complete, and that if T reads a set of values ​​based on a search condition, this set is not modified by other transactions until T is completed (i.e. T avoids the ghost phenomenon). In terms of a lock-based implementation, a SERIALIZABLE transaction obtains locks before reading or writing objects, including locks on sets of objects that it needs to remain unchanged (see Section 17.5.1) and keeps them until the end, according to Strict 2PL. .Say no to plagiarism. Get a tailor-made essay on “Why Violent Video Games Should Not Be Banned”? Get the original test Ensures that T only reads changes made by committed transactions and that no values ​​read or written by T are modified by another transaction until T is complete. . However, T could experience the ghost phenomenon; for example, while T is examining all Sailors records with rating = 1, another transaction might add a new Sailors record of that type, which is missed by T. Ttransaction sets the same locks as a SERIALIZABLE transaction, except that it does not perform index locking; that is, it only locks individual objects, not sets of objects. Ensures that T only reads changes made by committed transactions and that no values ​​written by T are modified by another transaction until T is complete. However, a value read by T may well be modified by another transaction while T is still in progress, and T is exposed to the phantom problem. The transaction obtains exclusive locks before writing objects and retains these locks until the end. It also obtains shared locks before reading objects, but these locks are released immediately; their only effect is to ensure that the transaction that last modified the object is complete. (This guarantee relies on the fact that each SQL transaction obtains exclusive locks before writing objects and retains exclusive locks until completion.) Transaction T can read changes made to an object by a current transaction; Obviously, the object can be modified further while T is in progress, and T is also vulnerable to the ghost problem. Ttransaction does not obtain shared locks before reading objects. This mode represents the greatest exposure to uncommitted changes to other transactions; so much so that SQL prohibits such a transaction from making changes itself - a READ UNCOMMITTED transaction must have a READ ONLY access mode. Since such a transaction does not obtain any locks to read objects and is not allowed to write objects (and therefore never requests exclusive locks), it never requests a lock. The isolation level is generally the most secure and is recommended for most transactions. However, some transactions can run with a lower isolation level, and the number..