Docsity

Database System Implementation: Concurrency Control and Two-Phase Locking, Study notes of Computer Science

Toggle sidebar
bg1
1
DB18
CS 4420 Database System Implementation
More TP
Ling Liu
Associate Professor
College of Computing, Georgia Tech
2
DB18
Lecture Outline
Review of Last Lectures
Concurrency Control
ÆTwo Phase Locking (2PL) (Binary Locks + Share and Exclusive
Locks)
ÆS/X locks with Increment Lock, Update Lock
ÆMultiple Granularity Locks (IS, IX, SIX …)
ÆPhantoms Phenomenon
ÆTree-based CC
ÆValidation CC
Today’s Lecture
ÆRecoverable Schedule
ÆAvoid cascading rollback + Strict Schedule
ÆNested Transactions
ÆView Serializability
pf3
pf4
pf5

Partial preview of the text

Download Database System Implementation: Concurrency Control and Two-Phase Locking and more Study notes Computer Science in PDF only on Docsity!

1

CS 4420 Database System Implementation

More TP

Ling Liu Associate Professor College of Computing, Georgia Tech

DB

Lecture Outline

„ Review of Last Lectures

Concurrency Control

Æ Two Phase Locking (2PL) (Binary Locks + Share and Exclusive Locks) Æ S/X locks with Increment Lock, Update Lock Æ Multiple Granularity Locks (IS, IX, SIX …) Æ Phantoms Phenomenon Æ Tree-based CC Æ Validation CC

„ Today’s Lecture

Æ Recoverable Schedule Æ Avoid cascading rollback + Strict Schedule Æ Nested Transactions Æ View Serializability

3

Chapters to Read:

„ Chapter 8: (read all sections)

„ Chapter 9:

z skim 9.

„ Chapter 10:

z Read 10.1, 10.2, 10. z skim 10.4, 10.5, 10.6, 10.

DB

Locking Schemes

„ Binary

„ Shared + Exclusive

„ Extending the S/X locking scheme with new

lock

„ Examples

z Increment Lock

z Update Lock

z Intentional Lock (IS, IX, SIX)

7

Deadlock Avoidance: Conservative 2 PL

Conservative 2 PL (static) : requires a transaction T to

  • pre-declare all the read set of items and write set of items; and lock all the items it accesses before T begins execution.
  • If any of the pre-declared items can not be locked, T does not lock any item at all. Instead, T waits and tries again until all the items are available for locking.
  • Conservative 2 PL is deadlock-free

Obtain lock Release lock

BEGIN END

Transaction period of duration data item use

No. of locks

Phase 1 Phase 2

DB

Strict 2 PL In addition to the Basic 2 PL , and Conservative 2 PL , there is another version of 2 PL: Strict 2 PL :

  • A transaction does not release any of its locks until after it terminates (by committing)
  • Strict 2 PL is not deadlock-free, unless combined with conservative 2 PL.
  • But it helps to overcome the update lost problem.
  • If all transactions in a schedule S follow the strict 2PL protocol, S is called a strict schedule. Hold locks until the end.

Obtain lock Release lock

BEGIN (^) period of END Transactionduration data item use

No. of locks

Concurrency Control Methods

Æ Pessimistic Concurrency Control

„ Locking Techniques for Concurrency Control „ Ensuring Serializability by Two-Phase Locking „ 2PL if every transaction in the schedule S satisfies the 2PL protocol, S is guaranteed to be serializable, „ Conservative 2PL –Deadlock free „ strict 2PL – recoverable „ Deaklocks

Æ Optimistic Concurrency Control