1 / 11

Concurrency Control Enforcing Serializability by Locks

Concurrency Control Enforcing Serializability by Locks. Krishna Nitin Tenali. INTRODUCTION. Enforcing serializability by locks Locks Locking scheduler Two phase locking. Locks. It works like as follows : A request from transaction Scheduler checks in the lock table

garren
Télécharger la présentation

Concurrency Control Enforcing Serializability by Locks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Concurrency ControlEnforcing Serializability by Locks Krishna Nitin Tenali

  2. INTRODUCTION • Enforcing serializability by locks • Locks • Locking scheduler • Two phase locking

  3. Locks • It works like as follows : • A request from transaction • Scheduler checks in the lock table • Generates a serializable schedule of actions.

  4. Consistency of transactions • Actions and locks must relate each other • Transactions can only read & write only if it has a lock on the database elements involved in the transaction. • Unlocking an element is compulsory. • Legality of schedules • No two transactions can acquire the lock on same element without the prior one releasing it.

  5. Locking scheduler • Grants lock requests only if it is in a legal schedule. • Lock table stores the information about current locks on the elements.

  6. The locking scheduler (contd.) • A legal schedule of consistent transactions but unfortunately it is not a serializable.

  7. Locking schedule (contd.) • The locking scheduler delays requests in order to maintain a consistent database state.

  8. Two-phase locking • Guarantees a legal schedule of consistent transactions is conflict-serializable. • All lock requests proceed all unlock requests. • The growing phase: • Obtain all the locks and no unlocks allowed. • The shrinking phase: • Release all the locks and no locks allowed.

  9. Working of Two-Phase locking • Assures serializability. • Two protocols for 2PL: • Strict two phase locking : Transaction holds all its write locks till commit / abort. • Rigorous two phase locking : Transaction holds all locks till commit / abort. • Two phase transactions are ordered in the same order as their first unlocks.

  10. Failure of 2PL. • 2PL fails to provide security against deadlocks. • T1: l1(A); r1(A); A:=A+100; w1(A); l1(B); u1(A); r1(B); B:=B+100; w1(B); u1(B); • T2: l2(B); r2(B); B:=B*2; w2(B); l2(A); u2(B); r2(A);A:=A*2; w2(A); u2(A);

  11. Thank You

More Related