concurrency control technique

Upload: inderjith-jayaraj

Post on 01-Jun-2018

225 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Concurrency Control Technique

    1/25

    Module - 5Module - 5Transaction Management,Concurrency Control and

    Distributed System

  • 8/9/2019 Concurrency Control Technique

    2/25

    What is Concurrency?What is Concurrency?

    Allowing multiple users to accessthe data contained within adatabase at the same time

  • 8/9/2019 Concurrency Control Technique

    3/25

  • 8/9/2019 Concurrency Control Technique

    4/25

    e"g" internet ban!inge"g" internet ban!ing

    acilityacility'ou want to pay your telephone bills using

    the on-line bill payment acility"(")og on to *S+) site, enter username and

    password"o to bill inormation section

    ."Choose online payment -/ lin! will connectto ur ban!0"1nter ur username and password gi2en to u

    by ban!5"Authorise a und tanser

    3"'ou instruct the ban! to debit 4S (5 romur a6c and credit the same to the *S+) a6c

    These collections o operations that orm asingle logical unit o wor! are calledtransactions"

  • 8/9/2019 Concurrency Control Technique

    5/25

    The AC%D properties oThe AC%D properties oTransactionTransactionAtomicity$ Transactions are atomic 7all

    or nothing8Consistency$ 1&ecution o a transaction

    preser2es the consistency o thedatabase%solation $ Transactions do not

    interact6interere with one another9

    transactions act as i they areindependentDurability$ 1:ects o a completed

    transaction are persistent

  • 8/9/2019 Concurrency Control Technique

    6/25

    To gain a betterTo gain a betterunderstanding o AC%Dunderstanding o AC%Dpropertiesproperties)et Ti be a transaction that

    transers ;5 rom account A toaccount *" this transaction can be

    de A-59

    write7A89

    read7*89*=> *59

    write 7*89

  • 8/9/2019 Concurrency Control Technique

    7/25

    AtomicityAtomicity

    Transaction should either ta!eplace completely or nothingshould happen in case o ailure

    This is handled by a componentcalled transaction managementcomponent and ensured by the

    database itsel"

  • 8/9/2019 Concurrency Control Technique

    8/25

    ConsistencyConsistency

    Sum o A and * be unchanged bythe e&ecution o the transaction"4esponsibility o the programmer

    who codes the transaction toensure consistency

  • 8/9/2019 Concurrency Control Technique

    9/25

    DurabilityDurability

    Ater the e&ecution o transactionis completed successully thenthere should not be any loss o

    data corresponding to thetranser o unds e2en i a systemailure occurs"

  • 8/9/2019 Concurrency Control Technique

    10/25

    Durability is ensured byDurability is ensured by

    eithereitherThe updates carried out by thetransaction ha2e been written to dis!beore the transaction completes%normation about the updates carried

    out by the transaction and written todis! is su@cient to enable the databaseto reconstruct the updates when thedatabase system is restarted ater the

    ailure"1nsuring durability is the responsibility o

    a component o database system calledthe reco2ery management component"

  • 8/9/2019 Concurrency Control Technique

    11/25

    %solation%solationDb is temporarily inconsistent while the

    transaction to transer unds rom A to * ise&ecuting, with the deduced total writtento A and the increased total yet to be

    written to *" % a second concurrentlyrunning transaction reads A and * at thisintermediate point and computes A*,which gi2es an inconsistent 2alue

    To a2oid this problem 1&ecute transactions serially6 other solutions

    1nsuring isolation is the responsibility o acomponent called Concurrency-Control

    Component

  • 8/9/2019 Concurrency Control Technique

    12/25

    Transaction StateTransaction State

    Aborted= a transaction which does notcomplete its e&ecution successully4olled *ac!= signals unsuccessul end-

    o-transaction" %t tells the transaction

    manager that something has gonewrong, the database might be in aninconsistent state and all theoperations that had been done so arhas been rolled bac! or undone

    Committed= a transaction thatcompletes its e&ecution successullyTerminated= a transaction that has

    either committed or aborted

  • 8/9/2019 Concurrency Control Technique

    13/25

    State Diagram o aState Diagram o a

    TransactionTransactionActive

    Partiallycommitt

    ed

    Committed

    FailedAborte

    d

  • 8/9/2019 Concurrency Control Technique

    14/25

    Acti2e= the initial state9 thetransaction stays in this state whileit is e&ecutingartially Committed= ater the

  • 8/9/2019 Concurrency Control Technique

    15/25

    Transactions andTransactions and

    SchedulesSchedulesTransaction is a series or list oactionsActions that can be e&ecuted by a

    transaction include reads and writeso database obects1ach transaction must speciy as its

  • 8/9/2019 Concurrency Control Technique

    16/25

    System logSystem log

    the system needs to essentiallymaintain a trac! record o alltransaction operations that are

    ta!ing place and that are li!ely toa:ect the status o the database"

    This inormation is called a

    System logE and may becomeuseul when the system is tryingto reco2er rom ailures"

  • 8/9/2019 Concurrency Control Technique

    17/25

    )et T reer to a uniFuetransaction id, generatedautomatically whene2er a new

    transaction is encountered andthis can be used to uniFuelyidentiy the transaction" Then the

    ollowing entries are made withrespect to the transaction T"

  • 8/9/2019 Concurrency Control Technique

    18/25

  • 8/9/2019 Concurrency Control Technique

    19/25

    ScheduleSchedule

    A list o actions 7reading, writing, aborting,or committing8 rom a set o concurrenttransactions and the order6arrangement inwhich two actions o a transaction Tappear in a schedule must be the same as

    the order in which they appear in T

    47A8

    W7A8 47*8 W7*8

    47C8

    W7C8

    A schedule in2ol2ing two transactions

    T( T

  • 8/9/2019 Concurrency Control Technique

    20/25

    Complete Schedule $ a schedule thatcontain an abort or a commit or each

    transaction whose actions are listed in it"

    Serial Schedule $ i the actions o di:erenttransactions are not interlea2ed $ i"e"transactions are e&ecuted rom start to

  • 8/9/2019 Concurrency Control Technique

    21/25

    A Complete Schedule= A schedule S on transactions T(, T,KK"" Tn is said to be

    a Complete ScheduleE i the ollowingconditions are satis

  • 8/9/2019 Concurrency Control Technique

    22/25

    Concurrent 1&ecutions oConcurrent 1&ecutions o

    TransactionsTransactionsTransaction processing systems

    allow multiple transactions to runconcurrently

    Cause se2eral complications withconsistency o the dataood reasons or allowing

    concurrencyTransaction consists o multiple steps"

    Some in2ol2e %6# acti2ity and somein2ol2e C acti2ity

  • 8/9/2019 Concurrency Control Technique

    23/25

  • 8/9/2019 Concurrency Control Technique

    24/25

    There may be a mi& o transactionsrunning on a system i"e" some short andsome long"

    Serial Transaction= a short transaction mayha2e to wait or a preceding longtransaction to complete which leads tounpredictable delays in running atransaction"

    % the transactions are operating ondi:erent parts o the database, then it isbetter to let them run concurrentlysharing the C cycles and dis! accesses

    among them

  • 8/9/2019 Concurrency Control Technique

    25/25

    Ad2antages o ConcurrentAd2antages o Concurrent1&ecution1&ecution4educes the unpredictable delays

    in running transactions"

    4educes the a2erage responsetime, the a2erage time or atransaction to be completed ater

    it has been submitted"