<aside> πŸ’‘ Concurrency Control

the method that the DBMS uses to ensure β€œcorrect” results for concurrent operations on a shared object

1. Latches Overview


<aside> πŸ’‘ Locks

<aside> πŸ’‘ Latches

Locks Latches
Separate … User Transaction Threads
Protect … Database Contents In-Memory Data Structures
During … Entire Txns Critical Sections
Modes … S, X, Update, Intention R, W
Deadlock Detection & Resolution Avoidance
… by … Waits-fir, Timeout, Aborts Coding Discipline
Kept in … Lock Manager Protected Data Structure

1.1 Modes

Untitled

1.2 Implementations

  1. Blocking OS Mutex
    1. Simple to use (System native)
    2. Non-scalable
  2. Test-and-Set Spin Latch (TAS)
    1. Very efficient (single instruction to latch/unlatch)
    2. Non-scalable, not cache-friendly, not OS-friendly
  3. Reader-Writer Latches
    1. Allows for concurrent readers
    2. Must manage read/write queues to avoid starvation
    3. Can be implemented on top of spin latches

2. Hash Table Latching


Easy to support concurrent access due to the limited ways threads access the data structure.

To resize the table, take a global write latch on the entire table

Approaches:

  1. Page Latches β†’ Each page has its own reader-writer latch that protects its entire contents.
  2. Slot Latches β†’ Each slot has its own latch.
    1. Can use a single-mode latch to reduce meta-data and computational overhead.