Top Banner
Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004
27

Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

Dec 26, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

Concurrency Control in Distributed Databases.

By :-Rishikesh Mandvikarrmandvik[at]engr.smu.eduMay 1, 2004

Page 2: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

2

Topics

Serializability Theory Centralized Databases Distributed Databases

Lock Based Concurrency Control Algorithms Centralized (2PL, S2PL) Distributed (C2PL, PC2PL, D2PL)

Optimistic Concurrency Control

Page 3: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

3

Serializability Theory [13]

Page 4: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

4

Serializability Theory [13]

Page 5: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

5

Serializability Theory extended to Distributed Database [14]

Fragmentation Horizontal Vertical Hybrid

Replication Synchronous Replication

ROWA Protocol Voting

Asynchronous Replication

Page 6: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

6

Concurrency Control algorithms

Pessimistic Optimistic

Locking Timestamp ordering

Hybrid

Centralized

Primary copy

Distributed

Centralized

Conservative

Multi-version

LockingTimestamp

ordering

Classification of CC Algorithms [14]

Page 7: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

7

Locking based CC Algorithms

Centralized 2PL (Relaxed S2PL)S2PL

DistributedC2PL PC2PL D2PL

Page 8: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

8

2 Phase locking (2PL) [13]

Rules: Growing phase: “A txn that has to read/write a data object first has

to request a read/write lock on it.”

Shrinking phase: “A txn cant request additional locks once it

releases a lock.”

Page 9: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

9

Number of locks

Transaction

Locks acquired

Locks released

Lock-point

Lock Graph for 2PL

Page 10: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

10

Strict 2 Phase Locking (S2PL) [13]

Rules: Growing phase: “A txn that has to read/write a data object first has

to request a read/write lock on it.”

Non - Shrinking phase: “Txn releases all locks only when it completes.”

Page 11: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

11

Number of locks

Transaction

Locks acquired

Locks held till transaction completion

Lock-point

Locked data items used

Lock Graph for S2PL

Page 12: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

12

2PL, S2PL [13]

Page 13: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

13

2PL, S2PL

Differences2PL

Cascading aborts Conflict serializable schedules (not all) High concurrency

S2PL No cascading aborts Serializable schedules Low concurrency

Page 14: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

14

Centralized 2PL

TM TM

LM

DPDP

Local data Local data

User application User application

Replica control protocol

C2PL

Site#1 Site#2

Page 15: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

15

Centralized 2PL [14]

ConsFailure of primary siteBottleneck situationCommunication links

Page 16: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

16

Primary Copy 2PL [14]

Lock on primary copy necessary Lock management at the primary-copy sites

only Pros

Reduces load at central site Cons

Deadlock handling is partially centralized

Page 17: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

17

Distributed 2PL [14]

TM TM

LM LM

DPDP

Local data Local data

User application User application

Replica control protocol

D2PL

Site#1 Site#2

Page 18: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

18

Distributed 2PL [14]

Pros Lock management independency

Cons Complex deadlock handling required Communication cost

Page 19: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

19

Optimistic Concurrency Control [13][14]

Txns assumed to have no conflictsPrivate workspace areaValidation of txns before write phase

Page 20: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

20

Optimistic Concurrency Control [13][14]

Txn phases: Read and Compute

read from database and write into private workspace

Validate Timestamps assigned over here Check for conflict with concurrent txns

Write Copy into database if validation successful

Page 21: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

21

Optimistic Concurrency Control [13][14]

For Ti and Tj where TS(Ti) < TS(Tj) Validation Criteria

All phases of Ti execute before TjTi ends before write phase of Tj and Ti doesn’t

modify data read by TjTi finishes its read phase before Tj finishes its read

phase and they both don’t read/write any common data

Page 22: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

22

Optimistic Concurrency Control [13][14]

Validation For validating Tj w.r.t committed txn Ti where

TS(Ti) < TS(Tj) Maintain a list of read/write object list for Tj Other cant commit while Tj is validated Once Validated, write phase allowed to finish Bottleneck situation

Page 23: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

23

Optimistic Concurrency Control [13][14]

Advantages Increased concurrency with a good “mix” of txns. Better than Lock based systems

Disadvantages Bottleneck situation Maintaining read/write list for every txn Copying the private space to the database Long txns

Page 24: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

24

Optimistic Concurrency Control [13][14]

DisadvantagesLong txns

Read/write list would be very long Chance of Restart is proportional to the square of its

size [9]

Page 25: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

25

Research

Optimistic CC algorithmIBM’s IMS FASTPATH (Centralized DBMS)OCC in Distributed DBMS

Page 26: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

26

Conclusion

Serializability Theory Lock Based Systems Optimistic CC algorithms

Timestamp Ordering

Page 27: Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.

27

Questions??