Skip to content

๐Ÿ“š Database Internals: Transactions, Concurrency Control & Crash Recovery - Comprehensive lecture notes covering ACID, isolation levels, locking protocols (2PL), MVCC, timestamp ordering, WAL, and ARIES recovery. Uses real world examples. PostgreSQL-focused.

Notifications You must be signed in to change notification settings

rathishkumar/lecture-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Database Transactions, Concurrency Control and Recovery

Guest Lecture Series โ€“ Lecture Notes Repository

Welcome!

This repository contains all lecture notes, diagrams, and examples used in the Database Internals guest lectures. The goal is to help you understand how a database actually works beneath SQL, specifically how it handles many users at once and how it keeps your data safe.

๐ŸŽฏ What Youโ€™ll Learn

By going through these modules, youโ€™ll understand:

  • How databases ensure ACID guarantees
  • How transactions run without interfering with each other
  • Why anomalies like dirty reads or deadlocks happen
  • How modern databases (PostgreSQL, MySQL, etc.) implement locks, timestamps, MVCC, and WAL
  • How databases recover safely after a crash

We use a simple, intuitive analogy throughout the course:

A Movie Seat Booking System โ€” to explain concurrency, conflicts, and isolation.

๐Ÿ“š Modules Overview

Part 1: Concurrency Control

# Module Description
01 Transaction Fundamentals What is a transaction? Understanding ACID, transaction lifecycle, and the basics of locking.
02 Isolation Levels Dirty reads, non-repeatable reads, phantoms, write skew, and how databases prevent them.
03 Two-Phase Locking (2PL) Shared vs. exclusive locks, growing & shrinking phases, strict 2PL, and deadlocks.
04 Timestamp Ordering &OCC How databases handle concurrencywithoutlocks using timestamps and optimistic validation.
05 MVCC How snapshot isolation works. Version chains, visibility rules, and why vacuuming is needed.

Part 2: Crash Recovery

# Module Description
06 Crash Recovery Techniques Why recovery is hard. Introducing Write-Ahead Logging (WAL) and Shadow Paging.
07 ARIES Recovery The standard recovery algorithm:Analysis โ†’ Redo โ†’ Undo.

๐Ÿ› ๏ธ Whatโ€™s Inside This Repo

  • Lecture Notes for each module
  • SQL examples to replicate anomalies and test locking behavior
  • Diagrams explaining MVCC snapshots, WAL logs, lock schedules, and recovery phases
  • A consistent example throughout the course: Movie Seat Booking

๐Ÿš€ How to Use This Repository

  • Start with Module 1 โ€“ each module builds on the previous one.
  • Try the SQL snippets โ€“ run them on a local PostgreSQL instance to observe locks, waits, and anomalies.
  • Refer to the diagrams inside the image/ folder whenever you need a visual explanation.
  • Move through the modules in order for the best learning experience.

๐Ÿ”‘ Quick Glossary

  • Atomicity: A transaction is all-or-nothing
  • Isolation: Transactions shouldnโ€™t interfere with each other
  • Serializability: The final result should look like transactions ran one-by-one
  • Deadlock: Two transactions waiting for each other forever
  • WAL: Log is written first, data page later
  • LSN: ID used to order all log records
  • Dirty Page: Modified in memory but not yet saved to disk

๐Ÿ“– Reference Materials

These are the primary sources and recommended readings used while preparing the lecture notes:

Books

University Course

๐Ÿ“ฌ For Questions

If you have questions about the concepts or need clarification, feel free to reach out on LinkedIn: Rathish Kumar B

๐Ÿค Contributions

Found a typo? Want to fix a diagram or improve an explanation?

Feel free to open a PR - contributions are welcome.

Just tell me!

About

๐Ÿ“š Database Internals: Transactions, Concurrency Control & Crash Recovery - Comprehensive lecture notes covering ACID, isolation levels, locking protocols (2PL), MVCC, timestamp ordering, WAL, and ARIES recovery. Uses real world examples. PostgreSQL-focused.

Topics

Resources

Stars

Watchers

Forks