Docsity

Two Phase Locking-Transaction Processing For E Commerce-Assignment Statment, Exercises of Transaction Processing for E Commerce

Toggle sidebar
bg1
CSEP 545 Transaction Processing for E-Commerce 1/18/2012
Assignment 3 1
Assignment 3
Problem 1
A transaction is strict two-phase locked if it is two-phase locked and holds all of its locks
until after it commits.
A history is strict two-phase locked if it can be augmented with lock and unlock
operations such that every transaction in the history is strict two-phase locked.
A history is normally-strict two-phase locked if it can be augmented with lock and unlock
operations such that every lock operation immediately precedes the read or write
operation that it synchronizes and every transaction in the history is strict two-phase
locked.
A history is two-phase locked if it can be augmented with lock and unlock operations
such that every transaction in the history is two-phase locked.
Notice that in a two-phase locked or strict two-phase locked history, a transaction can
execute a lock operation long before the read or write operation that it synchronizes. This
is not the case for normally-strict two-phase locked history.
Answer these questions for the histories below.
a) Is it normally-strict two-phase locked? If so, add lock operations to demonstrate
it.
b) If not, is it strict two-phase locked? If so, add lock operations to demonstrate it.
c) If not, is it two-phase locked? If so, add lock operations to demonstrate it.
d) If not, draw the serialization graph to find out if it is serializable or not.
Histories (differences from H1 are in bold):
H1: r1[y] r1[x] r2[x] w1[y] c1 w2[y] c2
H2: r1[y] r1[x] r2[x] w2[x] w1[y] c1 w2[y] c2
H3: r1[y] r1[x] r2[x] w1[y] w2[y] c2 c1
H4: r1[y] r1[x] r2[x] w2[x] r3[y] w1[y] c1 w3[z] c3 w2[y] c2
Extra credit : Is it possible for a history to be strict two-phase locked but not normally-
strict two phase locked? If so, give an example. If not, give a proof.
Problem 2
Consider a data manager that uses two-phase locking. Suppose all transactions are single-
threaded sequential programs, so no transaction can have more than one outstanding read
or write request that is blocked. Could a transaction be involved in more than one
deadlock? Explain your answer.
docsity.com
pf2

Partial preview of the text

Download Two Phase Locking-Transaction Processing For E Commerce-Assignment Statment and more Exercises Transaction Processing for E Commerce in PDF only on Docsity!

CSEP 545 Transaction Processing for E-Commerce 1/18/

Assignment 3 1

Assignment 3

Problem 1

A transaction is strict two-phase locked if it is two-phase locked and holds all of its locks until after it commits.

A history is strict two-phase locked if it can be augmented with lock and unlock operations such that every transaction in the history is strict two-phase locked.

A history is normally-strict two-phase locked if it can be augmented with lock and unlock operations such that every lock operation immediately precedes the read or write operation that it synchronizes and every transaction in the history is strict two-phase locked. A history is two-phase locked if it can be augmented with lock and unlock operations such that every transaction in the history is two-phase locked.

Notice that in a two-phase locked or strict two-phase locked history, a transaction can execute a lock operation long before the read or write operation that it synchronizes. This is not the case for normally-strict two-phase locked history.

Answer these questions for the histories below. a) Is it normally-strict two-phase locked? If so, add lock operations to demonstrate it. b) If not, is it strict two-phase locked? If so, add lock operations to demonstrate it. c) If not, is it two-phase locked? If so, add lock operations to demonstrate it. d) If not, draw the serialization graph to find out if it is serializable or not.

Histories (differences from H 1 are in bold):

H 1 : r 1 [y] r 1 [x] r 2 [x] w 1 [y] c 1 w 2 [y] c 2

H 2 : r 1 [y] r 1 [x] r 2 [x] w 2 [x] w 1 [y] c 1 w 2 [y] c 2

H 3 : r 1 [y] r 1 [x] r 2 [x] w 1 [y] w 2 [y] c 2 c 1

H 4 : r 1 [y] r 1 [x] r 2 [x] w 2 [x] r 3 [y] w 1 [y] c 1 w 3 [z] c 3 w 2 [y] c 2

Extra credit : Is it possible for a history to be strict two-phase locked but not normally- strict two phase locked? If so, give an example. If not, give a proof.

Problem 2

Consider a data manager that uses two-phase locking. Suppose all transactions are single- threaded sequential programs, so no transaction can have more than one outstanding read or write request that is blocked. Could a transaction be involved in more than one deadlock? Explain your answer.

docsity.com

CSEP 545 Transaction Processing for E-Commerce 1/18/

Assignment 3 2

Problem 3

Suppose each transaction is a sequential program with no internal concurrency (i.e., no multi-threading). Consider the following three transactions:

T 1 = r 1 [x,y] w 1 [x]

T 2 = r 2 [x] w 2 [z]

T 3 = r 3 [z] r 3 [y] w 3 [y]

a) Suppose the data manager is using two-phase locking. Suppose it receives the transactions’ reads and writes in the following sequence (i.e., the operations may execute in a different order than this): H 1 : r 1 [x,y] r 2 [x] w 1 [x] w 2 [z] r 3 [z] r 3 [y] w 3 [y] The transactions also submitted commit operations but the commits are not shown in the above sequence. Add each transaction’s commit operation to the earliest spot in the sequence where the data manager could have received that commit.

b) Answer the same question for this sequence (the difference is highlighted in bold):

H 2 : r 1 [x,y] r 2 [x] w 1 [x] r 3 [z] w 2 [z] r 3 [y] w 3 [y]

docsity.com