Presentation is loading. Please wait.

Presentation is loading. Please wait.

SHUJAZ IBRAHIM CHAYLASY GNOPHANXAY FIT, KMUTNB JANUARY 05, 2010 Distributed Database Systems | Dr.Nawaporn Wisitpongphan | KMUTNB Based on article by :

Similar presentations


Presentation on theme: "SHUJAZ IBRAHIM CHAYLASY GNOPHANXAY FIT, KMUTNB JANUARY 05, 2010 Distributed Database Systems | Dr.Nawaporn Wisitpongphan | KMUTNB Based on article by :"— Presentation transcript:

1 SHUJAZ IBRAHIM CHAYLASY GNOPHANXAY FIT, KMUTNB JANUARY 05, 2010 Distributed Database Systems | Dr.Nawaporn Wisitpongphan | KMUTNB Based on article by : PHILIP A. BERNSTEIN AND NATHAN GOODMAN

2  Introduction : Concurrency  Transaction Processing Model Definitions DDBMS Architecture Centralized TP Model Two-Phase Commit Distributed TP Model  Concurrency Control Decomposition  Other Concurrency Control Method Certifiers  References Outline 2

3 Introduction 3  Concurrency Control Coordinating concurrent access to a DB in a multiuser DBMS Main problem: Preventing DB updates from one user interfering with DB retrieval or updates of another In DDBMS this problem is more complex due to ○ Users may access data stored in many computers ○ Concurrency control mechanism at one computer cannot instantaneously know about interactions at other computers

4 Introduction cont.  E.g. concurrency control anomalies 4 Connection A... SELECT row1... UPDATE row1... Connection B... SELECT row1... UPDATE row1 Lost update anomaly User ATimeUser B Read Employee 100 - Update Salary - Write Employee 100 - Read Employee 101 - Update Salary - Write Employee 101 - - etc 1 2 3 4 5 6 7 8 9 10 11 12 13 - - Sum = 0.0 - Read Employee 100 - Sum = Sum + Salary - Read Employee 101 - Sum = Sum + Salary - - - etc Inconsistent retrieval anomaly

5 Definitions 5 DDBMS collection of sites interconnected by a network ○ Each site contain one or both software modules: a transaction manager (TM) or a data manager (DM) TM s supervise interactions between users and DDBMS DM s manage the actual DB Logical data items : X, Y, Z stored at any DM or redundantly on several DMs Logical DB state : assignment of values to logical data items Stored data item : stored copy of logical data item, for X stored copies denoted by x1,…xm Stored DB state : assignment of values to stored data Transactions: sequence of read and write operations on data items that logically functions as one unit of work ○ Each transaction must leave the DB in a consistent state if the DB is consistent when the transaction begins ○ Concurrency control algorithms make all of their decisions on the basis of the data items a transaction reads and writes Logical readset / writeset : logical data items a transaction reads / writes Stored readsets / writesets : stored data items a transcation reads / writes

6 DDBMS Architecture Transactions communicate with TMs In response to commands from transactions, TMs issue commands to DMs Each transaction supervised by single TM Transaction-TM interface four operations: READ(X), WRITE(X, new- value), BEGIN, END. DMs manage data TM-DM interaction in forms the core of the TP model 6 DDBMS architecture

7 Centralized TP Model 7 One TM and one DM executing at one site A transaction T has operations ○ BEGIN () {TM initializes a private workspace for T} ○ READ(X) { TM check X exist in T’s workspace Return value to T Else { TM issues dm-read(x) DM retrieve a copy of X from DB Return the value to T Put value in T’s workspace } ○ WRITE(X, new-value) { TM check X exist in T’s workspace update X = new-value Else { create X Assign X = new-value } ○ END () { For each X updated by T { TM issues dm-write(x) DM updates X in the stored db to value of X in T’s workspace } T’s finished executing Discard workspace }

8 Centralized TP Model cont. 8 DBMS may restart T any time before a dm-write has been processed Each dm-write permanently updates values in the DB, and we cannot restart T during this time, since it would reflect partial effects of the transaction DBMS avoid such partial results by having the property atomic commitment ○ Either all of a transaction’s dm-writes are processed or none are ○ Standard implementation of atomic commitment is a procedure called two-phase commit

9 Two-Phase Commit 9 Transaction T is updating data items X and Y When T issues its END two-phase commit begins ○ First Phase DM issues prewrite commands for X and Y Prewrite commands instruct DM to copy values of X and Y to secure storage If DBMS fails during this phase, no harm done. Since updates have not been copied to the stored DB ○ Second Phase TM issues dm-write commands for X and Y This command copies values of X and Y into the store DB If DBMS fails during this phase, the DB may contain incorrect information But system can recover later by using the values stored on secure storage Recovery reads values of X and Y from secure storage and resumes the commitment activity

10 Distributed TP Model TMs and DMs may run at different sites and movement of data between a TM and a DM can be expensive DDBMS can use query optimization procedures to reduce the cost Problem of atomic commitment is aggravated in a DDBMS ○ T is updating x, y, z stored at DM x, DM y, DM z ○ Suppose T’s TM fails after issuing dm-write( x ), before issuing dm-write for y and z ○ At this point DB is incorrect ○ In centralized DBMS this not harmful since no transaction can access DB until the TM recovers ○ In DDBMS, other TMs remain operational and can access the incorrect DB ○ To avoid this problem, in addition to specifying data items to be copied onto secure storage, prewrite is modified to specify which other DMs are involved in the commitment activity 10

11 Distributed TP Model cont. 11 A transaction T has operations ○ BEGIN () {TM initializes a private workspace for T} ○ READ(X) { TM check X exist in T’s workspace Return value to T Else { TM issues dm-read(x i ) to the DM where x i is stored DM retrieve a copy of x i from DB Return the value to T Put value in T’s workspace } ○ WRITE(X, new-value) { TM check X exist in T’s workspace update X = new-value Else { create X Assign X = new-value } ○ END () { ######Two-phase commit begins ###### For each X updated by T and for each stored copy x i of X { TM issues prewrite(x i ) DM copies value of X onto secure storage internal to the DM } For each logical data item updated by T { dm-write(x i ) DM copies value x i of from secure storage into the stored DB } T’s execution is finished }

12 Concurrency control Decomposition 12 1. Serializability 2. A paradigm for concurrency Control

13 Serializability  Let E denote an execution of transactions T 1..... T n,. E is a serial execution if no transactions execute concurrently in E.

14 Serializability cont.

15 A Paradigm for Concurrency Control  Theorem 1: rw and ww Synchronization technique  Theorem 2: Bern.

16 Other Concurrency control Method 16 Certification Approach ○ dm-reads and prewrites are processes by FCFS with no synchronization ○ DMs maintain summary information about rw and ww conflicts, which they update every time an operation is processed ○ dm-reads and prewrites are never blocked or rejected even when there is a conflict ○ When T issues its END, DBMS decides whether or not to certify, and thereby commit, T ○ Synchronization is accomplished entirely by restarts, never by blocking ○ Decision to restart or not is made after the transaction has finished executing ○ Assumes that most executions are serializable ○ Includes summarization algorithm for storing information about dm-reads and prewrites ○ Certification algorithm for using summary information to certify transactions when they terminate ○ Main problem in summarization algorithm is avoiding the need to store information about already-certified transactions ○ Main problem in certification algorithm is obtaining a consistent copy of the summary information

17 Other Concurrency control Method cont. 17 Certification Using the → Relation ○ Construct the → relation as dm-reads and prewrites are processed (T j → T k ) ○ Pieces of → are distributed among the sites ○ To certify a transaction the system checks that → is acyclic, hence guarantees serializability ○ All sites must be checked to certify any transaction. Even sites at which the transaction never accessed data must participate in the cycle checking of →. ○ Since this problem is not solved yet, the certification approach is impractical in a distributed environment

18


Download ppt "SHUJAZ IBRAHIM CHAYLASY GNOPHANXAY FIT, KMUTNB JANUARY 05, 2010 Distributed Database Systems | Dr.Nawaporn Wisitpongphan | KMUTNB Based on article by :"

Similar presentations


Ads by Google