1 / 21

CIS 720

CIS 720. Concurrency Control. Timestamp-based concurrency control. Assign a timestamp ts(T) to each transaction T. Each data item x has two timestamps: rt(x): timestamp of the last transaction that read x wt(x): timestamp of the last transaction that

anson
Download Presentation

CIS 720

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIS 720 Concurrency Control

  2. Timestamp-based concurrency control • Assign a timestamp ts(T) to each transaction T. • Each data item x has two timestamps: rt(x): timestamp of the last transaction that read x wt(x): timestamp of the last transaction that wrote x

  3. If T requests r(x) if wt(x) > TS(T) then abort T else update rt(x) = max(rt(x), TS(T)) If T request w(x) if rt(x) > TS(T) then if rt(x) < TS(T) and wt(x) > TS(T) if rt(x) < TS(T) and wt(x) < TS(T)

  4. Optimistic Concurrency Control • Assume that there are no conflicts • Get sequence number and access variables • At commit time, check to see if any conflicts occurred • If yes then abort else commit

  5. Atomicity • Ensure that a set of actions is performed atomically: all or none • Distributed transactions require the subtransactions to be atomic

  6. Each site votes “yes” or “no”. • A decision to commit is made only if all sites vote yes. Else the decision is to abort. • If any one site commits, then eventually all sites must commit • If any one site aborts then eventually all sites must abort

  7. A site cannot reverse its decision • If there are no failures and all sites vote to commit then the decision must be to commit • No message loss. Messages arriving at a failed site are lost. FIFO delivery • No false timeout

  8. Two phase commit • Coordinator: - send prepare message to all cohorts - wait for votes from all cohorts - If at least one vote is no then decide abort; send abort to all cohorts else decide commit; send commit to all cohorts

  9. Cohort: - wait for a prepare message send vote to coordinator if vote is no then decide abort else wait for message from coordinator if message is abort then decide abort else decide commit

  10. Timeout events: Cohort timeout waiting for prepare: decide abort Coordinator timeout waiting for a vote: decide abort; send abort message Cohort timeout waiting for decision: contact other cohorts; If it finds a cohort that has decided then make the same decision; otherwise, it blocks

  11. Recovery action: Cohort recovers: - not yet voted then decide abort - Not yet decided: communicate with other cohorts; if it finds a cohort that has decided then make the same decision; Otherwise, block

  12. Coordinator recovers: - If crashed before receiving all votes then decide abort; send abort messages to all cohorts - else, complete the protocol

  13. Three Phase Commit • Coordinator: - send prepare message to all cohorts - wait for votes from all cohorts - If at least one vote is no then decide abort; send abort to all cohorts else send precommit to all cohorts wait for ack from all cohorts decide commit send commit message to all cohorts

  14. Cohort: - wait for a prepare message send vote to coordinator if vote is no then decide abort else wait for message from coordinator if message is abort then decide abort else if message is precommit then send ack to coordinator wait for commit message decide commit

  15. Whenever at least one operational site is in its uncertain period, no other site, either operational or failed, can have decided commit.

  16. Timeout actions • Timeout events: Cohort timeout waiting for prepare: decide abort Coordinator timeout waiting for a vote: decide abort; send abort message Coordinator timeout waiting for an ack decide commit and send commit message to all cohorts

  17. Cohort timeout waiting for precommit or abort or commit: contact other cohorts and elect a new coordinator. The new coordinator polls the cohorts to find their status. If any cohort has not voted or has aborted then decide abort. If any cohort has committed then decide commit. If all operational cohorts are uncertain then decide abort. Otherwise, the new coordinator executes the three phase commit protocol by sending precommit messages.

More Related