C ONCURRENCY C ONTROL Prasun Dewan Department of Computer Science - - PowerPoint PPT Presentation

c oncurrency c ontrol
SMART_READER_LITE
LIVE PREVIEW

C ONCURRENCY C ONTROL Prasun Dewan Department of Computer Science - - PowerPoint PPT Presentation

C ONCURRENCY C ONTROL Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill dewan@cs.unc.edu C ONCURRENCY C ONTROL Issue Description Session Management How do distributed users create, destroy, join, and


slide-1
SLIDE 1

CONCURRENCY CONTROL

Prasun Dewan Department of Computer Science University of North Carolina at Chapel Hill dewan@cs.unc.edu

slide-2
SLIDE 2

2

CONCURRENCY CONTROL

Issue Description

Session Management How do distributed users create, destroy, join, and leave collaborative sessions? Single-user Interface What are the application semantics if there is a single user in the session? Coupling What is the remote feedback of a user command and when is it given? Access Control How do we ensure that users do not execute unauthorized commands? Concurrency Control How do we ensure that concurrent users do not execute inconsistent commands?

slide-3
SLIDE 3

3

Window System I/O Relayer & Output Broadcaster Window Application User 1

PROBLEM IN SHARED WINDOW SYSTEMS

Window System I/O Relayer User 2 Window System I/O Relayer User 3 leftButton ^, w1, x1, y1 press leftButton Multiple users can indeed generate input sequence that cannot be generated by single user press leftButton leftButton ^, w1, x2, y2 Can break (explicit/implicit) assertions of collaboration-unaware code Problem occurs because of interleaved execution

slide-4
SLIDE 4

4

PROBLEM IN SHARED MODEL SYTEMS

slide-5
SLIDE 5

5

PROBLEM IN SHARED MODEL SYSTEMS

slide-6
SLIDE 6

6

SYNCHRONIZATION MODEL

6 Shared data User 1 User 2 Synchronization logic (BeginTransaction Operation* EndTransaction)*

Users submit operations in transactions

Operations are validated w.r.t. concurrent

  • perations

Schedules (interleaved transactions)

slide-7
SLIDE 7

7

TRADITIONAL CORRECTNESS CRITERIA: SERIALIZABILITY

 Concurrent transactions execute as if they were

submitted one after the other.

7 serializable schedules all possible schedules

slide-8
SLIDE 8

8

SERIALIZABILITY: DIFFERENT ITEMS

8 T1 R1(d1) W1(d1) T2 R2(d2) W2(d2) R1(d1) R2(d2) W2(d2) W1(d1) Commuting operations can be reordered Serializable! Serializable? R2(d2) R1(d1) W2(d2) W1(d1) R2(d2) W2(d2) R1(d1) W1(d1) T2 T1 T1T2

slide-9
SLIDE 9

9

DIFFERENT ITEMS

slide-10
SLIDE 10

10

SERIALIZABILITY: SAME ITEMS

10 T1 R1(d1) W1(d1) T2 R2(d1) R1(d1) R2(d1) W1(d1) Serializable? R2(d1) R1(d1) W1(d2) T2 T1 T1T2 Serializable! T2 should precede T1 No dependencies between commuting

  • perations
slide-11
SLIDE 11

11

SERIALIZABILITY: SAME ITEMS

11 T1 R1(d1) W1(d1) T2 R2(d1) W2(d1) T2 should precede T1 Serializable? T1 should precede T2 Not serializable! Cycle in the transaction graph! Reverse reads and writes?

slide-12
SLIDE 12

12

SERIALIZABILITY: SAME ITEMS

12 T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) T2 should precede T1 Serializable? T1 should precede T2 Not serializable!

slide-13
SLIDE 13

13

SERIALIZABILITY: MULTIPLE ITEMS

13 T1 W1(d1) W1(d2) T2 W2(d1) W2(d2) T2 should follow T1 Serializable? T1 should follow T2 Not serializable!

slide-14
SLIDE 14

14

SERIALIZABILITY: MULTIPLE ITEMS

14 T1 W1(d1) W1(d2) T2 W2(d1) W2(d2) T2 should follow T1 Serializable? T2 should follow T1 Serializable!

slide-15
SLIDE 15

15

SERIALIZABILITY

 R-W Serializability  R-R operations (on same item) commute and hence can

be reordered.

 R-W and W-W do not commute and hence cannot be

  • reordered. Cause R-W and W-W conflicts in non-

serializable transactions

15

slide-16
SLIDE 16

16

Window System I/O Relayer & Output Broadcaster Window Application User 1

SHARED WINDOW SYSTEMS

Window System I/O Relayer User 2 Window System I/O Relayer User 3 leftButtond, w1, x1, y1 press leftButton press leftButton leftButtond, w1, x2, y2 T1 W1(LB) W1(LB) T2 W2(LB) W2(LB) leftButtonu, w1, x1, y1 leftButtonu, w1, x2, y2 release leftButton release leftButton

slide-17
SLIDE 17

17

SHARED MODEL SYSTEMS

slide-18
SLIDE 18

18

SHARED MODEL SYSTEMS

W1(Price) R2(Price) R1(Price) W2(Price) Not serializable!

slide-19
SLIDE 19

19

CONCURRENT DRAWING: INITIAL STATE

slide-20
SLIDE 20

20

USER1 CHANGE NOT SEEN BY USER2

slide-21
SLIDE 21

21

MODELING CONCURRENT DRAWING

slide-22
SLIDE 22

22

FINE-GRAINED MODELING OF READ

W1(Line.Color) R2(Line.Size) R1(Line.Color) W2(Line.Size) Serializable!

slide-23
SLIDE 23

23

COARSE-GRAINED READ MODELING

W1(Line.Color) R2(Line) R1(Line) W2(Line.Size) Assuming whole line read Not Serializable!

slide-24
SLIDE 24

24

CONCURRENT DRAWING

slide-25
SLIDE 25

25

CONCURRENT DRAWING

slide-26
SLIDE 26

26

CONCURRENT DRAWING

slide-27
SLIDE 27

27

FINE-GRAINED MODELING

W1(Rectangle) R2(Line) R1(Rectangle) W2(Line) Serializable!

slide-28
SLIDE 28

28

COARSE-GRAINED MODELING

W1(Rectangle) R2(Drawing) R1(Drawing) W2(Line) Assuming whole drawing read Not Serializable!

slide-29
SLIDE 29

29

29

THE PROBLEM OF TRACING READS

 In interactive application, not clear what user has

read.

 Many collaborative systems take liberal approach,

not tracking them.

 Strict serializability would require conservative

approach of assuming everything on the display is read

 Eye and scroll tracking would help narrow down the

read data

slide-30
SLIDE 30

30

R/W VS. TYPE-SPECIFIC SERIALIZABILITY

30 T1 ls project/README edit project/README T2 mkdir project/src ls project/src T1 R(project) W(project) T2 W(project) R(project) Set operations: serializable R/W operations: not serializable

slide-31
SLIDE 31

31

31

SERIALIZABILITY

 Modeling ls as read and mkdir as write leads to directory-

independent, non-serializable case

 Using type-specific semantics leads to serializable case

slide-32
SLIDE 32

32

SYNCHRONIZATION SYSTEMS

 Provide synchronization on behalf of

applications

32 Shared data Application User 1 User 2 Synchronization system Consistency requirements Consistency criteria

slide-33
SLIDE 33

33

CONSISTENCY CRITERIA VS. REQUIREMENTS

33 consistency requirements consistency criteria all possible schedules

slide-34
SLIDE 34

34

CONSISTENCY CRITERIA VS. REQUIREMENTS

34 Type specific Serializability R/W Serializability all possible schedules

slide-35
SLIDE 35

35

CONSISTENCY REQUIREMENTS & CRITERIA

 Consistency requirements:  specify the set of ideally allowable schedules.  “Users may concurrently add room reservations (that

don’t overlap), but may not concurrently change the same reservation.”

 Consistency criteria:  specify the set of actually allowed schedules.  “Users must access the set of reservations one at a time.”

35

slide-36
SLIDE 36

36

SYNCHRONIZATION SYSTEMS

 Provide synchronization on behalf of

applications

36 Shared data Application User 1 User 2 Synchronization system Consistency requirements Consistency criteria Given some consistency criteria how should the synchronization system check transactions for serializability?

slide-37
SLIDE 37

37

VALIDATION/CHECKING TIME

 Pessimistic  Early  Failure => block  Optimistic  Late  Failure => abort  Interactive transaction?

 Wasted human work not redoable perhaps

 Merging  Late, not serializable  Merging, new transaction to replace conflicting

transactions

37

slide-38
SLIDE 38

38

LOCKING: ONE ITEM

38 T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) L1(d1) F1(d1) L2(d1) F1(d1)

slide-39
SLIDE 39

39

SYNCHRONIZATION MODEL (REVIEW)

39 Shared data User 1 User 2 Synchronization logic (BeginTransaction Operation* EndTransaction)*

Users submit operations in transactions

Operations are validated w.r.t. concurrent

  • perations

Schedules (interleaved transactions)

slide-40
SLIDE 40

40

TRANSACTIONS (REVIEW)

 A (tomic)  Either all action of a transaction occur or none  C (onsistent)  Each transaction leaves shared state in a consistent

state, where consistency is application-defined

 I (solation)  Actions of concurrent transactions are isolated so that

together they leave the shared state in a consistent state

 D (urability)  Actions of a transaction persist – written to stable

storage) vs. persistent storage

 Stable – atomic write no errors;  Persistent – errors possible

slide-41
SLIDE 41

41

TRADITIONAL ISOLATION CRITERIA: SERIALIZABILITY (REVIEW)

 Concurrent transactions execute as if they were

submitted one after the other, leaving data in consistent state

41 serializable schedules all possible schedules

slide-42
SLIDE 42

42

VALIDATION/CHECKING TIME (REVIEW)

 Pessimistic  Early  Failure => block  Optimistic  Late  Failure => abort  Interactive transaction?

 Wasted human work not redoable perhaps

 Merging  Late, not serializable  Merging, new transaction to replace conflicting

transactions

42

slide-43
SLIDE 43

43

LOCKING: ONE ITEM (REVIEW)

43 T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) L1(d1) F1(d1) L2(d1) F1(d1)

slide-44
SLIDE 44

44

SYNCHRONIZATION MODEL (REVIEW)

44 Shared data User 1 User 2 Synchronization logic (BeginTransaction Operation* EndTransaction)*

Users submit operations in transactions

Operations are validated w.r.t. concurrent

  • perations

Schedules (interleaved transactions)

slide-45
SLIDE 45

45

TRANSACTIONS (REVIEW)

 A (tomic)  Either all action of a transaction occur or none  C (onsistent)  Each transaction leaves shared state in a consistent

state, where consistency is application-defined

 I (solation)  Actions of concurrent transactions are isolated so that

together they leave the shared state in a consistent state

 D (urability)  Actions of a transaction persist – written to stable

storage) vs. persistent storage

 Stable – atomic write no errors;  Persistent – errors possible

slide-46
SLIDE 46

46

TRADITIONAL ISOLATION CRITERIA: SERIALIZABILITY (REVIEW)

 Concurrent transactions execute as if they were

submitted one after the other, leaving data in consistent state

46 serializable schedules all possible schedules

slide-47
SLIDE 47

47

VALIDATION/CHECKING TIME (REVIEW)

 Pessimistic  Early  Failure => block  Optimistic  Late  Failure => abort  Interactive transaction?

 Wasted human work not redoable perhaps

 Merging  Late, not serializable  Merging, new transaction to replace conflicting

transactions

47

slide-48
SLIDE 48

48

LOCKING: ONE ITEM (REVIEW)

48 T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) L1(d1) F1(d1) L2(d1) F1(d1)

slide-49
SLIDE 49

49

LOCK COMPATIBILITY MATRIX

Data Item D Locked Unlocked Lock No Yes Issues (in collaborative systems)?

slide-50
SLIDE 50

50

LOCK COMPATIBILITY MATRIX (REVIEW)

Data Item D Locked Unlocked Lock No Yes Issues (in collaborative systems)?

slide-51
SLIDE 51

51

ISSUES

User Interface for Locking and Unlocking? Implementation of locking in a distributed collaborative environment? Lock Denial Semantics?

slide-52
SLIDE 52

52

LOCK DENIAL

Synchronous with timeout: Like synchronous but timeout returns false Non blocking: Callback when lock available, try again Synchronous: Programmed blocked until lock given Non blocking: No callback, polling Asynchronous: Callback when lock given UI Thread should not block

slide-53
SLIDE 53

53

ISSUES

User Interface for Locking and Unlocking? Implementation of locking in a collaborative environment? Lock Denial Semantics?

slide-54
SLIDE 54

54

USER-INTERFACE

Explicit/Implicit Locking Explicit/Implicit Unlocking

slide-55
SLIDE 55

55

UI: EXPLICIT/IMPLICIT LOCKING

Explicit Selection-implied

Lock O Append O, E1 Delete O, E2 Select Object  Lock Object + Select Object

Key-implied

Press Key  Lock Buffer + Process Key

Dragging-implied

Start Dragging  Lock Object + Start Dragging

slide-56
SLIDE 56

56

EXPLICIT/IMPLICIT UNLOCKING

Explicit Selection-implied

Append O, E1 Delete O, E2 Unlock O Unselect Object  Unselect object + Unlock

  • bject

Key-implied

Release Key  Unlock Buffer + Unlock object

Dragging-implied

Stop Dragging  Stop Dragging + Unlock Object Analogues of explicit/implicit locking

slide-57
SLIDE 57

57

IMPLICIT UNLOCKING

Tickle locks

Timeout Unlock Object

Preemptive locks

Lock Object Unlock Object + Lock Object

Tickle + Preemptive

Timeout + Lock Object Unlock Object + Lock Object Unlocked object may not be consistent! Unlocking user may be able to restore consistency of another user to essentially do a joint (nested) transaction

slide-58
SLIDE 58

58

Pro: Forgetting to unlock Pro: Low Wait Time Pro: Priority Pro: Consistency Lock O Insert O, E1 Delete O, D1 Unlock O Lock O Insert O, E2 … Lock O Insert O, E1 Lock O Insert O, E2 … Lock O Insert O, E1 Lock O Insert O, E2 …

CONSISTENCY VS CONCURRENCY

Non-Preemptive Preemptive Tickle-Locks

t > T

slide-59
SLIDE 59

59

ISSUES

User Interface for Locking and Unlocking? Implementation of locking in a collaborative environment? Lock Denial Semantics?

 

slide-60
SLIDE 60

60

IMPLEMENTATION

Already know how to share an object Need to share a locking model among multiple users

slide-61
SLIDE 61

61

REPLICATED VS CENTRALIZED

Model Interactor Model Interactor Model Interactor Interactor

slide-62
SLIDE 62

62

REPLICATED VS CENTRALIZED

Lock Model Lock Interactor Lock Model Lock Interactor Lock Model Lock Interactor Lock Interactor

slide-63
SLIDE 63

63

REPLICATED MODEL: ISSUES

Lock Model Lock Interactor Lock Model Lock Interactor Who solves the consistency problems of the consistency enforcer! Consistency issues of causality and concurrent

  • perations (to be addressed later)

Correctness and performance issues when model is non deterministic, accesses central resources, and has side effects

slide-64
SLIDE 64

64

DISTRIBUTED CONSENSUS PROBLEM

A set of processes have to agree on a common value (Byzantine generals) There may be failures in machines and communication Some processes may be malicious 2 Phase Commit : Coordinator takes vote in first phase and reports majority outcome in second Not to be confused with 2 Phase Locking (later) Will simply use the centralized cache solutions assuming no faults

slide-65
SLIDE 65

65

DISTRIBUTION UNAWARE INTERACTOR WITH MODEL CACHE/PROXY

Lock Model Interactor Lock Model Cache Model cache is a proxy that forwards write (lock, release)

  • peration without changing

its data Read operations (checking lock) access cached data

slide-66
SLIDE 66

66

REQUEST FOR LOCKED RESOURCE

Locked(I2) I1 Locked(I2) I2 Locked(I2) L

slide-67
SLIDE 67

67

REQUEST FOR UNLOCKED RESOURCE

Free I1 Free I2 Free L Locked(I1) Locked(I1) Locked(I1)

slide-68
SLIDE 68

68

FREE REQUEST FOR LOCKED RESOURCE

Locked(I2) I1 Locked(I1) I2 Locked(I2) F Free Free Free

slide-69
SLIDE 69

69

DISTRIBUTION UNAWARE INTERACTOR WITH MODEL CACHE/PROXY

Lock Model Interactor Lock Model Cache Model cache is a proxy that forwards write (lock, release)

  • peration without changing

its data Works? What if a message takes a long time to reach its destination? Acquire (L) and Release(F) Messages Read operations (checking lock) access cached data

slide-70
SLIDE 70

70

CONCURRENT LOCK REQUEST: MESSAGE TO SECOND LOCKER DELAYED

Free I1 Free I2 Free L Locked(I1) Locked(I1) Locked(I1) L

slide-71
SLIDE 71

71

CONCURRENT LOCK REQUEST : MESSAGE TO FIRST LOCKER DELAYED

Free I1 Free I2 Free L Locked(I1) Locked(I1) Locked(I1) L At most one cache will make transition from free to locked

slide-72
SLIDE 72

72

CONCURRENT FREE/LOCK REQUEST

Locked(I2) I1 Locked(I1) I2 Locked(I2) F Free L L Free Free Locked(I2) Caches are not consistent! Conservative: Local cache needs to be invalidated after each write Using application semantics for more concurrency? Locked(I2)

slide-73
SLIDE 73

73

IMMEDIATE FREEING (APPLICATION SEMANTICS)

Locked(I1) I1 Locked(I1) I2 Locked(I2) F Free L L Free Free Model cache is a proxy that forwards write (lock, release)

  • peration without changing

its data Release requests cause immediate freeing

slide-74
SLIDE 74

74

IMMEDIATE LOCKING?

Free I1 Free I2 Free L Locked(I1) Locked(I1) Locked(I2) L Weak/eventual consistency: pay the price Optimistic locks: undo changes if lock request denied Others may have seen changes – must do distributed undo if changes sent May have received changes from others, must undo non last changes or block them Locked(I1)

slide-75
SLIDE 75

75

OPTIMISTIC LOCKING

e

75

  • 1. Perform operation o and put it

in undo log

  • 3. Undo if lock request fails,

and perform deferred received actions

  • 2. Send permission to perform
  • peration and defer performing

received operations

PC 1

drag O

PC 3 PC 2 Lock Manager

Better response time

  • 4. Othewrise, toOthers()

send operation and perform deferred receive

  • perations

drag O

Undo Log Received Log

color O

slide-76
SLIDE 76

76

DISTRIBUTION UNAWARE INTERACTOR WITH MODEL CACHE/PROXY

Lock Model Interactor Lock Model Cache Model cache is a proxy that forwards lock operation without changing its data and forwards release request after changing its data Read operations (checking lock) access cached data Distributed vs software architecture

slide-77
SLIDE 77

77

SINGLE-USER PATTERN

I1 Free L Lockable Model Put locking semantics in model? May have more than one kind

  • f concurrency controller

(optimistic, pessimistic) May have more than one controller (access, concurrency)

slide-78
SLIDE 78

78

VETOERS VS OBSERVERS

Observer (Listener) Observable (Listenable) Model Interactor 1 Interactor 2 Interactor 3 Interactor 4 Change Announced write method Vetoer Vetoer 1 Vetoer 2 Vetoer 3 Vetoer 4 Permission Sought

slide-79
SLIDE 79

79

OBSERVER VS. VETOER

Observable Observer 1 register() register() Observer 2

  • peration
  • peration

Observers notified after event processing done

slide-80
SLIDE 80

80

OBSERVER VS. VETOER

Vetoeable Vetoer 1 register() register() Vetoer 2 Vetoers checked with before event processing done Feedback, so notifier must wait in distributed implementation

  • peration
  • peration
slide-81
SLIDE 81

81

VETOERS

 Like an observer, a vetoer can be registered with an

  • bject

 The object checks with each vetoer before making

and announcing change

 If a singe vetoer rejects change, then it is not made

  • r announced

 Java Beans comes with standard Vetoer interface

slide-82
SLIDE 82

82

VETOERS (REVIEW)

 Like an observer, a vetoer can be registered with an

  • bject

 The object checks with each vetoer before making

and announcing change

 If a singe vetoer rejects change, then it is not made

  • r announced

 Java Beans comes with standard Vetoer interface

slide-83
SLIDE 83

83

STANDARD JAVA VETOER INTERFACE

public interface VetoableChangeListener { public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException } Vetoing is not an exception (error)! Better to return a Boolean value

slide-84
SLIDE 84

84

CONTROLLED REPLICATED HISTORY

public class AControlledReplicatedHistory<ElementType> extends AReplicatedSimpleList<ElementType> implements ControlledReplicatedHistory<ElementType> { VetoableChangeSupport vetoableChangeSupport = new VetoableChangeSupport(this); public synchronized void replicatedAdd(ElementType aNewValue) { try { vetoableChangeSupport.fireVetoableChange( "IMHistory", null, aNewValue); } catch (PropertyVetoException e) { return; } super.replicatedAdd(aNewValue); } public void addVetoableChangeListener( VetoableChangeListener listener) { vetoableChangeSupport.addVetoableChangeListener(listener); } … Fitting list add to property change –

  • ld value is null, property name

could be also

slide-85
SLIDE 85

85

LIBRARY LISTENABLE EVENT QUEUE

Collaboration-Unaware Window System Collaboration-Unaware Application a^, w2, x, y a^, w2, x, y AnExtendible AWTEventQueue ListeningInput Distributer a^, w2, x, y InputController a^, w2, x, y

slide-86
SLIDE 86

86

HOW TO INTERCEPT, INJECT AND VETO WINDOW EVENTS

AnExtendible AWTEventQueue static getEventQueue() addEventQueueHandler (AWTEventQueueHandler) dispatchReceivedEvent (AWTEvent) getCommunication EventSupport() addVetoableChangeListener (VetoableChangeListener) The property value of fired vetoable change is the AWTEvent and the property name is to be ignored

slide-87
SLIDE 87

87

DISTRIBUTED + SOFTWARE ARCHITECTURE

Lock Model Interactor Lock Model Cache Vetoeable Vetoer 1 register()

  • peration

Local Model Cache = Vetoeable Model + Slave Model Vetoer Lock Model = Master Lock Model Assume each site has Slave Model Vetoer and one of these sites has Master Lock Model Three relevant user operations: write, lock, release

slide-88
SLIDE 88

88

TRACEABLE AWARE SLAVE UI THREAD

For each SlaveLockReleaseRequestMade by local user U If locked(U), setLock(U, false), to all, SlaveLockReleaseRequestSent Slave UI Thread (Vetoer) Slave UI Thread (Lock Releaser) For each SlaveLockGrantRequestMade by local user U if not locked(U), to all, SlaveLockGrantRequestSent Slave UI Thread (Lock Grantor) For each vetoable write received from local user U If not getLock(U), UserActionDenied

slide-89
SLIDE 89

89

TRACEABLE AWARE MASTER RECEIVING THREADS

For each MasterLockRequestReceived Master Receiving Thread For each MasterLockReleaseRequestReceived from user U If getLock(U), MasterLockReleased, to all, MasterLockReleaseStatusSent Master Receiving Thread If not isLocked(), MasterLockGranted, to all, MasterLockGrantStatusSent

slide-90
SLIDE 90

90

TRACEABLE AWARE SLAVE RECEIVING THREADS

Slave Receiving Thread For each SlaveLockRelease Received Provide awareness Slave Receiving Thread For each SlaveLockGrantReceived to A by U SlaveLockGranted; If (A == U), SlaveMyLockGrantMadeReceived Provide awareness SlaveLockReleased

slide-91
SLIDE 91

91

SUMMARY

Concurrency Control and Transactions Simple Locking – One Lock – and its distributed implementation Multiple Locks Multiple (Programmer-Defined) Lock Types Alternatives to Locking

 

Nested transactions

slide-92
SLIDE 92

92

LOCKING: ONE ITEM (REVIEW)

T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) T1 W1(d1) R1(d1) T2 W2(d1) R2(d1) L1(d1) F1(d1) L2(d1) F1(d1)

slide-93
SLIDE 93

93

LOCKING MULTIPLE ITEMS IN SAME ORDER

T1 W1(d1) T2 W2(d1) W2(d2) T1 T2 W2(d1) W2(d2) W1(d1) W1(d2) W1(d2) L1(d1) F1(d1) L2(d1) F2(d1) L1(d2) F1(d2) L2(d2) F2(d2) T2 performs an operation on each object after T1

slide-94
SLIDE 94

94

LOCKING MULTIPLE ITEMS IN DIFFERENT ORDER

T1 W1(d1) T2 W2(d2) W2(d1) T1 T2 W2(d2) W2(d1) W1(d1) W1(d2) W1(d2) L1(d1) F1(d1) L2(d2) F2(d2) L1(d2) F1(d2) L2(d1) F2(d1) Locks were freed too quickly! Get all locks before doing any

  • peration?

Early binding and keeps locks for longer than necessary A transaction has a growing phase when locks are added and not released Two phase locking Then it has a shrinking phase when locks are released but not freed

slide-95
SLIDE 95

95

NON TWO PHASE IN SAME ORDER

T1 W1(d1) T2 W2(d1) W2(d2) T1 T2 W2(d1) W2(d2) W1(d1) W1(d2) W1(d2) L1(d1) F1(d1) L2(d1) F2(d1) L1(d2) F1(d2) L2(d2) F2(d2) Locks shrink and then grow

slide-96
SLIDE 96

96

TWO PHASE LOCKING IN SAME ORDER

96 T1 W1(d1) T2 W2(d1) W2(d2) T1 T2 W2(d1) W2(d2) W1(d1) W1(d2) 12(d2) L1(d1) F1(d1) L2(d1) F2(d1) L1(d2) F1(d2) L2(d2) D1 freed after all locks gathered but before end of transaction

slide-97
SLIDE 97

97

NON TWO PHASE DIFFERENT ORDER

T1 W1(d1) T2 W2(d2) W2(d1) T1 T2 W2(d2) W2(d1) W1(d1) W1(d2) W1(d2) L1(d1) F1(d1) L2(d2) F2(d2) L1(d2) F1(d2) L2(d1) F2(d1)

slide-98
SLIDE 98

98

TWO-PHASE LOCKING DIFFERENT ORDER

98 T1 W1(d1) T2 W2(d2) W2(d1) T1 T2 W2(d2) W1(d1) W1(d2) L1(d1) L2(d2) L1(d2) L2(d1) Non serializable schedules lead to deadlocks A transaction has a growing phase when locks are added and not released Two phase locking Need deadlock detection schemes Then it has a shrinking phase when locks are released but not freed

slide-99
SLIDE 99

99

PROOF THAT 2PL  SERIALIZABILITY

Non-serializable == Cycles in transaction graph Transaction graph: T1 has edge to T2 if T2 performs some (non commuting) operation after some operation performed by T1 Cycles in transaction graph under 2PL will lead to deadlocks Proof by Contradiction There is a cycle but no deadlock Cycle: T1 accessed d1 before T2, and T2 accessed d2 before T1 No deadlock: T1 had both locks before T2 had any locks (or vice versa) No deadlock: No cycle

slide-100
SLIDE 100

100

LOCKING: ONE ITEM

100 T1 R1(d1) W1(d1) T2 R2(d1) W2(d1) T1 R1(d1) W1(d1) T2 R2(d1) W2(d1) L1(d1) F1(d1) L2(d1) F1(d1) Single lock for read and write? T2 ‘s read unnecessarily delayed

slide-101
SLIDE 101

101

LOCKING: ONE ITEM

T1 R1(d1) W1(d1) T2 R2(d1) T1 R1(d1) W1(d1) T2 R2(d1) L1(d1) F1(d1) L2(d1) F1(d1) T2 unnecessarily delayed

slide-102
SLIDE 102

102

TYPE-SPECIFIC LOCKS

T1 R1(d1) W1(d1) T2 R2(d1) T1 R1(d1) W1(d1) T2 R2(d1) RL1(d1) RF1(d1) RL2(d1) RF2(d1) Concurrent reads allowed WL1(d1) WF1(d1) Concurrent read and write not allowed

slide-103
SLIDE 103

103

READ/WRITE LOCKS

Data Item D Read Locked Write Locked Unlocked Read Lock Write Lock No Yes Yes No Yes No

slide-104
SLIDE 104

104

S(HARED)/(E)X(CLUSIVE) LOCKS

S X S Yes No X No No More compact representation

slide-105
SLIDE 105

105

Session Application Window Paragraph/Drawing

LOCK GRANULARITY

Char Fine-grained Coarse-grained (Floor Control) Variable-grained Finer Control  More Concurrency  More Lock/Unlock Operations  More Locking Overhead Comparison and Ideal granularity?

slide-106
SLIDE 106

106

FIXED-GRAIN LOCKING

T1 R1(d1) W1(d1.B) T2 R2(d1.A) T1 R1(d1) W1(d1.B) T2 R2(d1.A) S1(d1) SF1(d1) S2(d1) SF2(d1) T1 unnecessarily waits for T2 to finish write X1(d1) XF1(d1)

slide-107
SLIDE 107

107

VARIABLE-GRAINED HIERARCHICAL LOCKING

T1 R1(d1) W1(d1.B) T2 R2(d1.A) T1 R1(d1) W1(d1) T2 R2(d1.A) S1(d1) SF1(d1) S2(d1.A) SF2(d1.A) More concurrency X1(d1.B) XF1(d1.B) Each lock in a tree independent, look only at lock at your level?

slide-108
SLIDE 108

108

ANCESTOR DEPENDENCE

T1 W1(d1) T2 R2(d1.A) T1 W1(d1) T2 R2(d1.A) X1(d1) SF1(d1) S2(d1.A) SF2(d1.A) Lock operation must consider lock at ancestor nodes # searches ~ height of tree - O(h)) Search cost? Descendent dependence?

slide-109
SLIDE 109

109

DESCENDENT DEPENDENCE

T1 W1(d1) T2 R2(d1.A) T1 W1(d1) T2 R2(d1.A) X1(d1) SF1(d1) S2(d1.A) SF2(d1.A) Lock operation must consider lock at descendent nodes # searches ~ nodes in tree - O (2h) Trade space for time? Assuming a node contains information only about locks at that node

slide-110
SLIDE 110

110

ANCESTOR DEPENDENCE (REVIEW)

T1 W1(d1) T2 R2(d1.A) T1 W1(d1) T2 R2(d1.A) X1(d1) SF1(d1) S2(d1.A) SF2(d1.A) Lock operation must consider lock at ancestor nodes # searches ~ height of tree - O(h)) Search cost? Descendent dependence?

slide-111
SLIDE 111

111

DESCENDENT DEPENDENCE (REVIEW)

T1 W1(d1) T2 R2(d1.A) T1 W1(d1) T2 R2(d1.A) X1(d1) SF1(d1) S2(d1.A) SF2(d1.A) Lock operation must consider lock at descendent nodes # searches ~ nodes in tree - O (2h) Trade space for time? Assuming a node contains information only about locks at that node

slide-112
SLIDE 112

112

INTENTION LOCKS

T1 W1(d1) T2 R2(d1.A) T1 W1(d1) T2 R2(d1.A) X1(d1) SF1(d1) S2(d1.A) SF2(d1.A) IS2(d1) Intention lock: a flag (synthesized attribute) in each ancestor of a locked node indicating the kind of lock, associated with a reference count incremented/decremented by lock and free operations ISF2(d1) Synthesized attribute: An attribute of a node that is a function of a descendent(IS) Inherited attribute: An attribute of a node that is a function of an ancestor(S)

slide-113
SLIDE 113

113

S(HARED)/(E)X(CLUSIVE) LOCKS

IS IX S SIX X IS IX S SIX X Yes Yes Yes Yes No Yes Yes No No No Yes No Yes No No Yes No No No No No No No No No IS: some descendent of the node will have a shared lock IX: some descendent of the node will have an exclusive lock SIX: shared lock on this node and an exclusive lock on some descendent (inherited and synthesized attribute)

slide-114
SLIDE 114

114

INTENTION LOCKS

T1 W1(d1) T2 R2(d1.A) T1 W1(d1) T2 R2(d1.A) X1(d1) SF1(d1) S2(d1.A) SF2(d1.A) IS2(d1) ISF2(d1) Re-order intention and shared locks?

slide-115
SLIDE 115

115

INTENTION LOCKS

T1 W1(d1) T2 R2(d1.A) T1 W1(d1) T2 R2(d1.A) X1(d1) SF1(d1) SF2(d1.A) S2(d1.A) ISF2(d1) Lock tree not consistent if the entire lock tree is not locked during its traversal IS2(d1) Earlier transaction delayed and can lead to unecessary deadlocks

slide-116
SLIDE 116

116

Session Application Window Paragraph/Drawing

LOCKING/UNLOCKING ORDER

Char IS IS IS S

slide-117
SLIDE 117

117

SHARED MODEL SYSTEMS

slide-118
SLIDE 118

118

SHARED MODEL SYSTEMS

W1(Price) R2(Price) R1(Price) W2(Price) What does time line mean here? Sync should be a first class operation known to the transaction system

slide-119
SLIDE 119

119

ALTERNATIVE READ MODELING

R1(Price) R2(Price) W1(Price) W2(Price) Neither transaction reads value of the

  • ther or overwrites

until synchronize (commit) occurs No incremental sharing

slide-120
SLIDE 120

120

READ, VALIDATION, WRITE PHASE

W1(Price) R2(Price) R1(Price) W2(Price) Validate T1 Write Validate System Abort T2 Read phase: shared

  • bject read but not

written Validation phase, assign time stamps and decide commit or abort Write phase Validation rules?

slide-121
SLIDE 121

121

OPTIMISTIC TRANSACTION RULES

 Optimistic concurrency control divides a transaction

into a read phase, a validation phase, and a writing phase

 Read phase: transaction reads shared items, and

performs writes on local buffers, with no checking taking place

 Validation phase: the system assigns time stamps to

transactions, and assumes transactions are serialized in order of these timestamps

 Write phase, the local writes of validated

transactions are made global.

 If a transaction is not validated wrt to another

transaction, one of them is aborted

slide-122
SLIDE 122

122

VALIDATION ALTERNATIVE

Transaction Ti is validated wrt to Tj, j > i, Ti finishes its write phase before Tj begins its read phase R2(O1) W2(O2) Validate T2 Equivalent of locks on same object serializing access W1(O1) R1(O1) Validate T1 Write Write

slide-123
SLIDE 123

123

VALIDATION RULES

W1(O2) R1(O1) Validate T1 Write Transaction Ti is validated wrt Tj, j > i, Tj does not read or write any items written by TI Equivalent of different locks on different objects Concurrent operations on same sets of object? W1(O4) R1(O3) Validate T2 Write

slide-124
SLIDE 124

124

VALIDATION RULES

W1(O1) R1(O1) Validate T1 Write Transaction Ti is validated if wrt Tj, j > i, if TJ does not read any of the items written by TI and transaction TI finishes its write phase before transaction TJ begins its write phase. Lack of incremental sharing does not make a difference when there is no R-W and W-R dependency W1(O1) R1(O2) Validate T2 Write

slide-125
SLIDE 125

125

VALIDATION RULES

W2(O1) R1(O1) Validate T1 Write W1(O1) Validate T2 Abort R-W dependencies (same as W-R dependencies) among concurrent transactions cause aborts Because no incremental sharing R1(O1) Locking would have allowed this schedule

slide-126
SLIDE 126

126

PROBLEMS OF INCREMENTAL SHARING

Cascaded abort because incremental results shared in pessimistic schemes W1(O1) R1(O1) W1(O2) R1(O1) User Abort Problem would not occur in optimistic transactions or if no W-R dependencies from transaction aborted by user System Abort R3(O2) System Abort In locking systems problem is avoided by keeping write lock until end of transaction

slide-127
SLIDE 127

127

VALIDATION/CHECKING TIME

 Early  Pessimistic  Late  Optimistic  Merging

slide-128
SLIDE 128

128

PESSIMISTIC VS. OPTIMISTIC CC

 Two alternatives to serializable transactions  Pessimistic  Prevent conflicting operation before it is executed  Implies locks and possibly remote checking  Optimistic  Abort conflicting operation after it executes  Involves replication, check pointing/compensating

transactions

slide-129
SLIDE 129

129

EARLY VS. LATE VALIDATION

 Per-operation checking

and communication

  • verhead

 No compression possible.  Prevents inconsistency.  Tight coupling:

incremental results shared

 Not functional if

disconnected

 Unless we lock very

conservatively, limiting concurrency.

 No per-operation checking,

communication overhead

 Compression possible.  Inconsistency possible

resulting in lost work.

 Allows parallel

development.

 Functional when

disconnected.

slide-130
SLIDE 130

130

MERGING

 Like optimistic  Allow operation to execute without local checks  But no aborts  Merge conflicting operations  E.g. insert 1,a || insert 2, b = insert 1, a; insert 3, b ||

insert 2, b; insert 1, a

 Serializability not guaranteed  Ignore reads  New transaction to replace conflicting transactions  Strange results possible

 E.g. concurrent dragging of an object in whiteboard

 App-specific

slide-131
SLIDE 131

131

HIERARCHICAL SHARED OBJECTS

Paper Abstract Introduction Para 1 Para 2

slide-132
SLIDE 132

132

HIERARCHICAL TRANSACTIONS VS. OBJECTS

T11: Fix Typos T12: Move Figures T1: Fix Paper Read Abstract Write Abstract Write Introduction Check and Fix Length Submit Paper Paper Abstract Introduction Para 1 Para 2 The actions are hierarchical rather than the data

slide-133
SLIDE 133

133

HIERARCHICAL VS. SERIAL TRANSACTIONS

T1: Fix Paper Check and Fix Length Submit Paper Read Abstract Write Abstract Write Introduction T11: Fix Typos T12: Move Figures T1: Fix Paper Read Abstract Write Abstract Write Introduction Check and Fix Length Submit Paper Sub transactions can execute in parallel but not sub operations

slide-134
SLIDE 134

134

HIERARCHICAL VS. FLAT TRANSACTIONS

T11: Fix Typos T12: Move Figures T1: Fix Paper T1: Fix Typos T2: Move Figures T3: Fix Paper Write Introduction Read Abstract Write Abstract Write Introduction Check and Fix Length Submit Paper Check and Fix Length Submit Paper Read Abstract Write Abstract Sub-transactions do not guarantee consistency and their results are not durable They are atomic and serializable wrt to each

  • ther

They get locks from parent and release locks to parent locks and write to parent uncommitted data Top level transaction gets shared object locks

slide-135
SLIDE 135

135

CONCURRENCY OF PARENT

T11: Fix Typos T12: Move Figures T1: Fix Paper Read Abstract Write Abstract Write Introduction Check and Fix Length Submit Paper Parent may wait until sub- transactions finish Parent may execute in parallel Subtransactions not serializable wrt to parent Ignore parent locks (but not versa) and override parent writes A la Java (Mesa) thread join Needed in this example

slide-136
SLIDE 136

136

ABORT SEMANTICS

T11: Fix Typos T12: Move Figures T1: Fix Paper Read Abstract Write Abstract Check and Fix Length Submit Paper Abort Write Introduction

slide-137
SLIDE 137

137

DIFFERENT ALTERNATIVE TRANSACTION

T11: Fix Typos T13: Move Figures T1: Fix Paper Read Abstract Write Abstract Check and Fix Length Submit Paper Write Conclusion Child aborts do not abort parent transaction, a parent can try alternative transactions

slide-138
SLIDE 138

138

NESTED TRANSACTIONS

 Like top-level, atomic and isolated wrt to siblings in

transaction tree

 Not unit of consistency or durability  Actions do not conflict with parent’s transactions.  In lock-based systems, can get a lock from parent in

weaker mode and then release lock to parent

 In optimistic schemes they write to parent’s data set  Parent’s actions conflict with child if parent executes

in parallel

 Child abort does not abort the parent, which can try

alternative sub-transactions

slide-139
SLIDE 139

139

TYPE SPECIFIC OPERATIONS

139 T1 ls project/README edit project/README T2 mkdir project/src ls project/src T1 R(project) W(project) T2 W(project) R(project) Set operations: serializable R/W operations: not serializable

slide-140
SLIDE 140

140

TYPE-SPECIFIC SERIALIZABILITY

 Modeling ls as read and mkdir as write leads to directory-

independent, non-serializable case

 Using type-specific semantics leads to serializable case

slide-141
SLIDE 141

141

TRANSACTION GRAPH

T1 T2 T1 performs operation X before T2 does operation Y D(X, Y)

slide-142
SLIDE 142

142

MODELING AN OBJECT AS A BLACKBOX: SERIALIZABILITY

Abstract Data Type (Black Box) Any getPrice() getPrice() setPrice()

setPrice(int) int getPrice()

D = D(Any, Any) Serializability: No cycles in D(any, any) relationship among concurrent transactions Not serializable T1 T2

slide-143
SLIDE 143

143

MODELING AN OBJECT AS A BLACKBOX: PREVENT CASCADED ABORTS

Abstract Data Type (Black Box) Any getPrice() setPrice()

setPrice(int) int getPrice()

D(Any, Any) No cascaded aborts: No D(any, any) relationship among concurrent transactions Not allowed if cascaded aborts are to be avoided T1 T2

slide-144
SLIDE 144

144

MODELING AN OBJECT AS A READ/WRITE REPOSITORY: SERIALIZABILITY

Abstract Data Type (R/W Repository) Read getPrice() getPrice() setPrice()

setPrice(int) int getPrice()

Serializability: No cycles in D = D2 U D3 U D4 relationship among concurrent transactions Serializable Write D1 = D(R , R) D2 = D(R , W) D3 = D(W , R) D4 = D(W , W) T1 T2

slide-145
SLIDE 145

145

MODELING AN OBJECT AS A BLACKBOX: PREVENT CASCADED ABORTS

Abstract Data Type (R/W Repository) getPrice() setPrice()

setPrice(int) int getPrice()

No cascaded aborts: No D(W, R) relationship among concurrent transactions Allowed if cascaded aborts are to be avoided Read Write D1 = D(R , R) D2 = D(R , W) D3 = D(W , R) D4 = D(W , W) T1 T2

slide-146
SLIDE 146

146

QUEUE

Queue<Element> (R/W Repository)

QEnter(Element e) Element QDelete()

E(X) QEnter(X) D(X) X = QDelete() Assume each element has a unique id assigned when it is entered into queue

slide-147
SLIDE 147

147

TRANSACTION GRAPH (REVIEW)

T1 T2 T1 performs operation X before T2 does operation Y D(X, Y) How to prevent non serializable transactions? How to prevent cascaded aborts

slide-148
SLIDE 148

148

MODELING AN OBJECT AS A BLACKBOX: SERIALIZABILITY (REVIEW)

Abstract Data Type (Black Box) Any getPrice() getPrice() setPrice()

setPrice(int) int getPrice()

D = D(Any, Any) Serializability: No cycles in D(any, any) relationship among concurrent transactions Not serializable T1 T2

slide-149
SLIDE 149

149

MODELING AN OBJECT AS A BLACKBOX: PREVENT CASCADED ABORTS (REVIEW)

Abstract Data Type (Black Box) Any getPrice() setPrice()

setPrice(int) int getPrice()

D(Any, Any) No cascaded aborts: No D(any, any) relationship among concurrent transactions Not allowed if cascaded aborts are to be avoided T1 T2

slide-150
SLIDE 150

150

MODELING AN OBJECT AS A READ/WRITE REPOSITORY: SERIALIZABILITY (REVIEW)

Abstract Data Type (R/W Repository) Read getPrice() getPrice() setPrice()

setPrice(int) int getPrice()

Serializability: No cycles in D = D2 U D3 U D4 relationship among concurrent transactions Serializable Write D1 = D(R , R) D2 = D(R , W) D3 = D(W , R) D4 = D(W , W) T1 T2

slide-151
SLIDE 151

151

MODELING AN OBJECT AS A BLACKBOX: PREVENT CASCADED ABORTS (REVIEW)

Abstract Data Type (R/W Repository) getPrice() setPrice()

setPrice(int) int getPrice()

No cascaded aborts: No D(W, R) relationship among concurrent transactions Allowed if cascaded aborts are to be avoided Read Write D1 = D(R , R) D2 = D(R , W) D3 = D(W , R) D4 = D(W , W) T1 T2

slide-152
SLIDE 152

152

QUEUE (REVIEW)

Queue<Element> (R/W Repository)

QEnter(Element e) Element QDelete()

E(X) QEnter(X) D(X) X = QDelete() Assume each element has a unique id assigned when it is entered into queue

slide-153
SLIDE 153

153

MODELING AN OBJECT AS A READ/WRITE REPOSITORY: SERIALIZABILITY

Queue<Element> (R/W Repository)

QEnter(Element e) Element QDelete()

E(A) D(C) E(B) Write Write Read Not serializable even though two transactions working at different ends of the queue T1 T2

slide-154
SLIDE 154

154

MODELING AN OBJECT AS A READ/WRITE REPOSITORY: NO CASCADED ABORTS

Queue<Element> (R/W Repository)

QEnter(Element e) Element QDelete()

E(A) D(C) Write Write Read Serializable but not allowed if cascaded aborts are to be avoided because of D(W, R) dependency T1 T2

slide-155
SLIDE 155

155

SUPPORTING QUEUE OPERATIONS DIRECTLY

Queue<Element>)

QEnter(Element e) Element QDelete()

E(A) E(C) E(B) Not serializable because in a serial schedule all elements of one transaction will be queued before or after another T1 T2

slide-156
SLIDE 156

156

SUPPORTING QUEUE OPERATIONS DIRECTLY

Queue<Element>)

QEnter(Element e) Element QDelete()

D(A) D(C) D(B) Not serializable because in a serial schedule all elements of one transaction will be dequeued before or after another T1 T2

slide-157
SLIDE 157

157

MODELING QUEUE OPERATIONS

Queue<Element>)

QEnter(Element e) Element QDelete()

E(A) D(C) E(B) Serializable because two transactions working at different ends of the queue We know that based on argument and return values of transactions The element dequeued by T2 is not an element queued by T1 T1 T2

slide-158
SLIDE 158

158

SUPPORTING QUEUE OPERATIONS DIRECTLY

Queue<Element>)

QEnter(Element e) Element QDelete()

D1 = E(e) , E(e’) D2 = E(e) , D(e’) D3 = E(e) , D(e) D4 = D(e) , E(e’) D5= D(e) , D(e’) Serializability: No cycles in D = D1 U D3 U D5 No D3 relationship in concurrent transactions Serializability? Avoiding cascaded aborts?

slide-159
SLIDE 159

159

S(HARED)/(E)X(CLUSIVE) LOCKS

E(e) D(e) D(null) E(e) E(e’) D(e) D(e’) D(null) N/A No Yes No N/A Yes No N/A No No No No No No Yes

slide-160
SLIDE 160

160

TYPE-SPECIFIC LOCKS

 Less information about operations available to locking

system more conservative it is about commuting and dependent operations

 No information  Serializability: no interleaving operations on an object  Cascaded aborts: no concurrency  R/W:  Serializability: No cycles in D(R,W), D(W,R), D(R,R)  No Cascaded aborts: No D(W,R) relationship among

concurrent transactions

 Queue-specific:  Serializability: Cycles allowed in D(E(e), D(e’)) and D(D(e),

E(e’))

 Cascaded aborts: No D(E(e), D(e)) relationship among

concurrent transactions

 A lock specifies kind of operation and element queued or

dequeued

 Kept until end of transaction

slide-161
SLIDE 161

161

CONCURRENCY CONTROL SUMMARY

 Transactions and ACID  Isolation: serializability and cascaded aborts  Explicit, implicit Locks  Locking implementation: Two phase commit, cache

incoherence

 Shared vs. exclusive locks  Two phase locking  Hierarchical locking and intention locks  Type-specific dependencies and locking  Optimistic transactions  Optimistic locks  Nested transactions

slide-162
SLIDE 162

162

EXTRA SLIDES

slide-163
SLIDE 163

163

S(HARED)/(E)X(CLUSIVE) LOCKS

Locks held until end of transaction to: remember which elements have been added removed prevent cascaded aborts E(e) D(e) E(e) E(e’) D(e) D(e’) N/A No Yes No No Yes No N/A Not clear we need to remember elements added removed if we have null row and column

slide-164
SLIDE 164

164

MODELING AN OBJECT AS A READ/WRITE REPOSITORY: SERIALIZABILITY

Queue<Element> (R/W Repository)

QEnter(Element e) Element QDelete()

E(A) D(C) E(B) Write Write Read Not serializable even though two transactions working at different ends of the queue T1 T2 There is indeed a D(W,R) relation between T1 and T2 contrary to what the recording says

slide-165
SLIDE 165

165

MODELING AN OBJECT AS A READ/WRITE REPOSITORY: NO CASCADED ABORTS

Queue<Element> (R/W Repository)

QEnter(Element e) Element QDelete()

E(A) D(C) Write Write Read Serializable but not allowed if cascaded aborts are to be avoided because of D(W, R) dependency T1 T2 There is indeed a D(W,R) relation between T1 and T2 contrary to what the recording says and so under R/W semantics it wull be disallowed

slide-166
SLIDE 166

166

SUPPORTING QUEUE OPERATIONS DIRECTLY

Queue<Element>)

QEnter(Element e) Element QDelete()

E(A) D(C) E(B) Serializable because two transactions working at different ends of the queue T1 T2

slide-167
SLIDE 167

167

NOT HOLDING LOCK UNTIL END OF TRANSACTION

Queue<Element>)

QEnter(Element e) Element QDelete()

E(A) D(A) E(B) T1 T2 LE(A) LE(B) FE(A) FE(B) LD(A) LD(C) FD(C) FD(A) D(C)

slide-168
SLIDE 168

168

S(HARED)/(E)X(CLUSIVE) LOCKS

E(e) D(e) D(null) E(e) E(e’) D(e) D(e’) D(null) N/A No Yes No N/A Yes No N/A No No No No No No Yes

slide-169
SLIDE 169

169

S(HARED)/(E)X(CLUSIVE) LOCKS

E(e) D(e) D(null) E(e) E(e’) D(e) D(e’) D(null) N/A No Yes No N/A Yes No N/A N/A No No No N/A N/A Yes

slide-170
SLIDE 170

170

S(HARED)/(E)X(CLUSIVE) LOCKS

E(e) D(e) D(null) E(e) E(e’) D(e) D(e’) D(null) N/A No Yes No N/A Yes No N/A N/A No No No N/A N/A Yes

slide-171
SLIDE 171

171

S(HARED)/(E)X(CLUSIVE) LOCKS

E(e) D(e) D(null) E(e) E(e’) D(e) D(e’) D(null) N/A No Yes No N/A Yes No N/A Yes No No No Yes Yes Yes Assume dequeue is non blocking

slide-172
SLIDE 172

172

S(HARED)/(E)X(CLUSIVE) LOCKS

E(e) D(e) D(null) E(e) E(e’) D(e) D(e’) D(null) N/A No Yes No N/A Yes No N/A Yes No No No Yes Yes Yes Assume dequeue is non blocking