Transactions and Concurrency

A transaction is an all-or-nothing unit that preserves ACID properties; concurrency control (such as two-phase locking) ensures interleaved transactions produce a serialisable schedule equivalent to some serial order.

Key formulas & points

Skim these first — then read the full notes below.

  • Isolation levels: READ UNCOMMITTED up to SERIALIZABLE
  • Anomalies: dirty read, non-repeatable read, phantom read
  • Write-ahead logging records changes before applying them

Topic details

Introduction

This topic covers reliable concurrent access. You study the ACID properties, the concurrency anomalies that arise without control, serialisability as the correctness criterion, two-phase locking, isolation levels, and write-ahead logging for recovery.

Key relations & formulas

Formulas (Indian textbook notation)

  • ACID:Atomicity,Consistency,Isolation,DurabilityACID: Atomicity, Consistency, Isolation, Durability

Formulas (Indian textbook notation)

  • twophaselocking:agrowingphaseacquireslocks,ashrinkingphasereleasesthemtwo-phase locking: a growing phase acquires locks, a shrinking phase releases them

Formulas (Indian textbook notation)

  • aserialisablescheduleisequivalenttosomeserialexecutiona serialisable schedule is equivalent to some serial execution

Notation and sign conventions

Relation 1 —
ACID:Atomicity,Consistency,Isolation,DurabilityACID: Atomicity, Consistency, Isolation, Durability

Formulas (Indian textbook notation)

  • ACID:Atomicity,Consistency,Isolation,DurabilityACID: Atomicity, Consistency, Isolation, Durability
Write this relation with symbols exactly as in Database System Concepts — Korth, Silberschatz & Sudarshan before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 2 —
twophaselocking:agrowingphaseacquireslocks,ashrinkingphasereleasesthemtwo-phase locking: a growing phase acquires locks, a shrinking phase releases them

Formulas (Indian textbook notation)

  • twophaselocking:agrowingphaseacquireslocks,ashrinkingphasereleasesthemtwo-phase locking: a growing phase acquires locks, a shrinking phase releases them
Write this relation with symbols exactly as in Database System Concepts — Korth, Silberschatz & Sudarshan before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.
Relation 3 —
aserialisablescheduleisequivalenttosomeserialexecutiona serialisable schedule is equivalent to some serial execution

Formulas (Indian textbook notation)

  • aserialisablescheduleisequivalenttosomeserialexecutiona serialisable schedule is equivalent to some serial execution
Write this relation with symbols exactly as in Database System Concepts — Korth, Silberschatz & Sudarshan before substituting numbers. Examiners award partial marks for a correct setup even when arithmetic slips.

Concept in depth

Transactions let multiple users share a database without corrupting it. Atomicity makes a transaction all-or-nothing, isolation makes concurrent transactions appear to run alone, and durability makes committed changes survive crashes — the last relying on write-ahead logging, which records intended changes before touching the data so recovery can redo or undo them. Correctness of concurrency is defined by serialisability: an interleaved schedule is acceptable only if it is equivalent to some serial order. Two-phase locking guarantees this by forbidding new lock acquisitions once any lock is released. Weaker isolation levels permit specific anomalies (dirty, non-repeatable and phantom reads) in exchange for more concurrency.

Assumptions and validity limits

State assumptions explicitly before using any relation for transactions and concurrency — steady state, uniform properties, linear elastic material, ideal gas, incompressible flow, etc., as applicable.
Wrong assumptions invalidate the entire solution even when the formula is correct. In Database Systems viva and GATE descriptive questions, listing valid assumptions often earns separate marks.

Step-by-step problem approach

1. Read the question and list given data with SI units (common in Database Systems papers).
2. Draw a neat labelled diagram where applicable — examiners in Indian universities award diagram marks even when arithmetic slips.
3. Identify which relation from this topic applies to transactions and concurrency.
4. Use equation 1:
ACID:Atomicity,Consistency,Isolation,DurabilityACID: Atomicity, Consistency, Isolation, Durability
.
5. Use equation 2:
twophaselocking:agrowingphaseacquireslocks,ashrinkingphasereleasesthemtwo-phase locking: a growing phase acquires locks, a shrinking phase releases them
.
6. Substitute values, compute, and verify units and sign (direction).
7. State conclusion in one line — e.g. safe/unsafe, stable/unstable, feasible/infeasible.

Applications & exam relevance

Transactions and Concurrency appears in enterprise applications. In Indian it software curricula this topic is tested because it connects theory to relational model and SQL.
GATE and semester exams often combine transactions and concurrency with earlier units — revise prerequisites before attempting mixed problems.
Industry interview panels sometimes ask: "Where did you use transactions and concurrency?" — answer with a lab, mini-project, or plant visit example if possible.

Common mistakes in exams

Students confuse the three read anomalies and which isolation level prevents each, forget that 2PL requires all locks acquired before any release, and equate any interleaving with a serialisable one. Overlooking that higher isolation costs concurrency is a practical gap.

Quick revision checklist

Before attempting transactions and concurrency problems, confirm you can:
1. Isolation levels: READ UNCOMMITTED up to SERIALIZABLE
2. Anomalies: dirty read, non-repeatable read, phantom read
3. Write-ahead logging records changes before applying them
Revise the solved examples in Database System Concepts — Korth, Silberschatz & Sudarshan and one previous-year GATE or university paper for this unit.

Worked examples

Try the problem first — open the solution when you are ready to check.

Isolation level for repeatable reads

Problem

A transaction reads the same row twice and must see the same value both times, but new matching rows appearing is acceptable. Which isolation level suffices?

Solution

REPEATABLE READ: it prevents dirty and non-repeatable reads (the row will not change), but may still allow phantom rows. Preventing phantoms too would require SERIALIZABLE.

Conceptual check — Transactions and Concurrency

Problem

In a Database Systems semester or GATE paper you are asked: "State the main assumption, the governing relation, and one practical consequence of transactions and concurrency." What should a complete answer include?

📖 Standard books (India)

  • Database System ConceptsKorth, Silberschatz & Sudarshan

    Read: Syllabus unit

    SQL, normalization, and transactions