***Welcome to ashrafedu.blogspot.com * * * This website is maintained by ASHRAF***

Posts

    Sunday 22 December 2019

    Optimistic Concurrency Control


    Optimistic Concurrency Control

    The optimistic method of concurrency control is based on the assumption that conflicts of database operations are rare and that it is better to let transactions run to completion and only check for conflicts before they commit.
    An optimistic concurrency control method is also known as validation or certification methods. No checking is done while the transaction is executing. The optimistic method does not require locking or time stamping techniques. Instead, a transaction is executed without restrictions until it is committed.
    In optimistic methods, each transaction moves through the following phases:
    • Read phase.
    • Validation or certification phase.
    • Write phase.
    Read phase: In this phase, the transaction T is read and executed. It is used to read the value of various data items and stores them in temporary local variables. It can perform all the write operations on temporary variables without an update to the actual database.

    Validation phase: In this phase, the temporary variable value will be validated against the actual data to see if it violates the serializability.
    Three rules to enforce serializability in validation phase −
                Rule 1 − Given two transactions Ti and Tj, if Ti is reading the data item which Tj is            writing, then Ti’s execution phase cannot overlap with Tj’s commit phase. Tj can commit        only after Ti has finished execution.
                Rule 2 − Given two transactions Ti and Tj, if Ti is writing the data item that Tj is reading, then Ti’s commit phase cannot overlap with Tj’s execution phase. Tj can start executing         only after Ti has already committed.
                Rule 3 − Given two transactions Ti and Tj, if Ti is writing the data item which Tj is also     writing, then Ti’s commit phase cannot overlap with Tj’s commit phase. Tj can start to            commit only after Ti has already committed.

    Write phase: If the validation of the transaction is validated, then the temporary results are written to the database or system otherwise the transaction is rolled back.

    No comments:

    Post a Comment