100 likes | 232 Views
Database System Principles 18.7 Tree Locking Protocol. CS257 Section 1 Spring 2012 Dhruv Jalota ID: 115. Index. Motivation B-Tree Protocol Why it works Example Precedence graph Proof. Motivation. Data elements are not hierarchically stored by containment but rather they are DISJOINT.
E N D
Database System Principles18.7 Tree Locking Protocol CS257 Section 1 Spring 2012 Dhruv Jalota ID: 115
Index • Motivation • B-Tree • Protocol • Why it works • Example • Precedence graph • Proof
Motivation • Data elements are not hierarchically stored by containment but rather they are DISJOINT. • A B-TREE is the ideal data structure to represent such a database since traversal to reach any data element would require beginning at the root. • Two-phase locking in such a situation makes concurrent use of DB by transactions impossible
B-TREE details • Basic DS: - Keeps records in sorted order - Uses partially full blocks to speed up insertion and deletion Locking structure: - Granularity is at node level. Smaller is not beneficial and entire tree is infeasible!
Tree protocol • Transaction’s first lock can be any node • Subsequent locks only if currently locked parent • Nodes unlocked any time • Cannot relock if released node, even if parent is still held • (As we can see – NOT 2PL)
Why it works • Implies a serial order on transactions in schedule • Define Ti < S Tj (order of precedence) • In schedule S, Ti and Tj lock common nodes, but Ti locks first
Example • Figure 18.30 from text book. • And figure 18.31
Precedence graph • Figure 18.32 from text book. • T1 < S T2 • T3 < S T2 • Acyclic graph means any topological order is an equivalent serial schedule • Thus, (T1, T3, T2) = (T3, T1, T2) • This is because nodes are touched in same order.
Proof for acyclic precedence graph giving equivalent schedules • If two transactions lock several elements in common, then they are all locked in the same order • Figure 18.33