Tải bản đầy đủ (.pdf) (49 trang)

Distributed Database Management Systems: Lecture 29

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (114.05 KB, 49 trang )

Distributed Database
Management Systems
Lecture 29


In the previous lecture
• Serializability Theory
• Serializability Theory
in DDBS.


In this Lecture
• Locking based CC
• Timestamp ordering based
CC.


• TM sends ops and
other information to LM
• LM checks the status
of data item
• Already Locked or not.


T1:

Read(x)

T2: Read(x)

x = x+1


Write(x)
Commit

x = x*2
Write(x)
Commit

Read(y)

Read(y)

y = y-1
y = y*2
Write(y)
Write(y)
Commit
Commit
S={wl1(x), R1(x), W1(x), lr1(x), wl2(x),
R2(x), W2(x), lr2(x), wl2(y), R2(y), W2(y),
lr2(y), C2,wl1(y), R1(y), W1(y), lr1(y), C1)


S={wl1(x), R1(x), W1(x), lr1(x),
wl2(x), R2(x), W2(x), lr2(x), wl2(y),
R2(y), W2(y), lr2(y), C2,wl1(y),
R1(y), W1(y), lr1(y), C1)

• Not a serial schedule
• Problem: Locks
released immediately-



Two-Phase Locking


• A transaction must not
attain a lock once it
releases a lock
• Or, it should not
release any lock until
it is sure it won’t need
any lock


• It creates growing
phase, shrinking phase
and a lock point
• Lock point determines
end of growing phase
and start of shrinking
phase


Any transaction that
follows 2-PL is
serializable.



• This 2-PL is difficult to

implement
–LM has to know that a Tr
has attained all locks
–Its not going to need a
released item again
–So we have strict 2-PL



Centralized 2PL
• The locking job is
designated to a single
site
• So only one site has
the Lock Manager



• Central site may
become a bottleneck
in case of too many
accesses
• Primary Copy 2-PL is
one solution


Data Processor
Partic Site

Coordinating

TM

Primary Site
LM

Data Processor
Partic Site


Distributed 2-PL


• That was it about
locking approach
• Next we see
timestamp-based
concurrency control.


• Serializabiltiy implemented
by assigning a
serialization order to
transactions
• Unique timestamps are
issued by TM at the
initiation of a transaction


• Timestamps should be
unique and monotonically

increasing
• Maintaining system wide
monotonically increasing
counter is difficult in DDBS
environment


• Timestamp then could
be a two tuple
consisting a counter
value and the site id.
• System clock can also
be used in stead.


Timestamp Ordering Rule
• Given two conflicting
operations Oij, Okl of Ti
and Tk, Oij is executed
first iff ts(Ti) < ts(Tk)
• Younger and older
transactions.


• TO scheduler checks
each operation against
conflicting operations
• Younger ones are
allowed, older refused-



• A TO scheduler is
guaranteed to generate
serial order
• However, needs to
know all operations in
advance


×