chapter

    Transactions, Concurrency Control and Recovery Notes for Gate Cs

    Transactions, Concurrency Control and Recovery notes for GATE CS: 40 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice q

    Transactions Concurrency Control and Recovery notes

    Chapter Roadmap: Transactions, Concurrency, and Recovery

    1
    ACID Properties and Concurrency Anomalies
    The foundation. Defines the rules of reliability and the specific logical errors that occur when concurrent transactions interfere.
    2
    Conflict Serializability and Schedule Equivalence
    The mathematical test. How to prove that an interleaved execution is logically equivalent to a safe, serial execution.
    3
    Recoverability, Cascading Rollback, and Crash Recovery
    Handling failures. Ensuring that aborted transactions do not corrupt committed ones, and the database can restart cleanly.
    4
    Two-Phase Locking and Lock-Based Concurrency Control
    The practical protocol. The actual mechanism databases use to guarantee serializability and prevent anomalies in real time.

    The Transaction: A Logical Unit of Work

    A transaction is a logical unit of work that contains one or more database operations (reads and writes).

    From the system's perspective, it is a sequence of low-level operations. From the user's perspective, it is a single, indivisible action.

    Core Principle

    A transaction must transition the database from one consistent state to another consistent state. It is the fundamental boundary for enforcing reliability, concurrency control, and recovery.

    Example: A funds transfer is one transaction. It involves:

    1. Read balance of Account A.
    2. Subtract amount from Account A.
    3. Write new balance to Account A.
    4. Read balance of Account B.
    5. Add amount to Account B.
    6. Write new balance to Account B.

    If any step fails, the entire transaction is treated as if it never happened.

    ACID Properties: The Four Pillars of Reliability

    The ACID properties are the mandatory guarantees provided by a Database Management System (DBMS) to ensure reliable processing of transactions.

    Property Core Guarantee Managed By
    Atomicity All or nothing. The transaction executes entirely or not at all. No partial effects. Recovery Manager (Undo logging)
    Consistency The transaction preserves all database integrity constraints, rules, and triggers. Application logic + DBMS constraints
    Isolation Concurrent transactions execute as if they were running strictly one after the other (serially). Concurrency Control Manager (Locking)
    Durability Once a transaction commits, its changes are permanent and survive any subsequent system crash. Recovery Manager (Redo logging)

    37 more cards in this chapter

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    Level 1: Warm-up

    Assertion (A): A schedule is conflict serializable if its precedence graph contains no cycles.

    Reason (R): The nodes of the precedence graph represent the data items, and the edges represent the transactions.

    Question 2
    Level 1: Warm-up

    According to the conflict serializability checklist, what is the correct chronological order of the first two steps?

    1. Check for cycles
    2. Identify conflicting operations
    3. Draw directed edges
    Question 3
    Level 1: Warm-up

    In the conflict serializability checklist, what is the immediate next step after confirming that the precedence graph has no cycles?

    Question 4
    Level 1: Warm-up

    Consider the schedule . When constructing the precedence graph for conflict serializability, how many distinct directed edges are drawn between the transaction nodes?

    Question 5
    Level 1: Warm-up

    A database management system provides four mandatory guarantees for every transaction. If a transaction successfully commits, its changes are permanent and will survive any subsequent system failure, power loss, or crash. This specific guarantee is known as:

    Question 6
    Level 1: Warm-up

    Two operations from different transactions access the exact same data item. According to the core rule of conflicting operations, what is the maximum number of write operations that can be present in this pair such that the pair is guaranteed to NEVER conflict?

    Question 7
    Level 1: Warm-up

    Consider the following statements about a conflict serializable schedule :

    Statement 1: is guaranteed to be free of concurrency anomalies like Lost Updates.

    Statement 2: must be conflict equivalent to every possible serial schedule of its transactions.

    Which of the statements is/are true?

    Question 8
    Level 1: Warm-up

    Match the following operation sequence with the correct edge drawn in the precedence graph.

    Sequence: occurs before

    Question 9
    Level 1: Warm-up

    Match the following schedule with the correct set of directed edges in its precedence graph.

    Schedule:

    Question 10
    Level 1: Warm-up

    Match the following schedule with the correct set of directed edges in its precedence graph.

    Schedule:

    Free preview ends here

    Login to view the complete notes

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Transactions, Concurrency Control and Recovery Notes for GATE CS

    Transactions, Concurrency Control and Recovery notes for GATE CS: 40 study cards covering concepts, formulas, shortcuts and exam traps, plus solved practice questions.

    Chapter Roadmap: Transactions, Concurrency, and Recovery

    1
    ACID Properties and Concurrency Anomalies
    The foundation. Defines the rules of reliability and the specific logical errors that occur when concurrent transactions interfere.
    2
    Conflict Serializability and Schedule Equivalence
    The mathematical test. How to prove that an interleaved execution is logically equivalent to a safe, serial execution.
    3
    Recoverability, Cascading Rollback, and Crash Recovery
    Handling failures. Ensuring that aborted transactions do not corrupt committed ones, and the database can restart cleanly.
    4
    Two-Phase Locking and Lock-Based Concurrency Control
    The practical protocol. The actual mechanism databases use to guarantee serializability and prevent anomalies in real time.

    The Transaction: A Logical Unit of Work

    A transaction is a logical unit of work that contains one or more database operations (reads and writes).

    From the system's perspective, it is a sequence of low-level operations. From the user's perspective, it is a single, indivisible action.

    Core Principle

    A transaction must transition the database from one consistent state to another consistent state. It is the fundamental boundary for enforcing reliability, concurrency control, and recovery.

    Example: A funds transfer is one transaction. It involves:

    1. Read balance of Account A.
    2. Subtract amount from Account A.
    3. Write new balance to Account A.
    4. Read balance of Account B.
    5. Add amount to Account B.
    6. Write new balance to Account B.

    If any step fails, the entire transaction is treated as if it never happened.

    ACID Properties: The Four Pillars of Reliability

    The ACID properties are the mandatory guarantees provided by a Database Management System (DBMS) to ensure reliable processing of transactions.

    Property Core Guarantee Managed By
    Atomicity All or nothing. The transaction executes entirely or not at all. No partial effects. Recovery Manager (Undo logging)
    Consistency The transaction preserves all database integrity constraints, rules, and triggers. Application logic + DBMS constraints
    Isolation Concurrent transactions execute as if they were running strictly one after the other (serially). Concurrency Control Manager (Locking)
    Durability Once a transaction commits, its changes are permanent and survive any subsequent system crash. Recovery Manager (Redo logging)

    Atomicity: The All-or-Nothing Guarantee

    Atomicity dictates that a transaction is an indivisible unit of work.

    • Success: All operations within the transaction are completed and reflected in the database.
    • Failure: If the transaction fails at any point (due to logic error, constraint violation, or system crash), the database is restored to its exact state before the transaction began.

    Mechanism: The DBMS maintains a log of all changes. If a transaction aborts, the Recovery Manager uses this log to undo any partial writes, guaranteeing no intermediate state is ever visible or permanent.

    Transactions, Concurrency Control and Recovery: Solved Questions with Step-by-Step Explanations (10 Problems)

    Question 1 · Databases MCQ

    Assertion (A): A schedule is conflict serializable if its precedence graph contains no cycles.

    Reason (R): The nodes of the precedence graph represent the data items, and the edges represent the transactions.

    1. A.

      Both A and R are true and R is the correct explanation of A

    2. B.

      Both A and R are true but R is NOT the correct explanation of A

    3. C.

      A is true but R is false

    4. D.

      A is false but R is true

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: The precedence graph uses transactions as nodes and conflicts as directed edges.

    Step 1: Evaluate Assertion (A). The golden rule of the precedence graph method is that an acyclic graph (no cycles) means the schedule is conflict serializable. Assertion (A) is true.

    Step 2: Evaluate Reason (R). The reason states that nodes are data items and edges are transactions. This is backwards. The nodes represent the transactions (), and the directed edges represent the conflicts (e.g., ). Reason (R) is false.

    Answer: A is true but R is false.

    Question 2 · Databases MCQ

    According to the conflict serializability checklist, what is the correct chronological order of the first two steps?

    1. Check for cycles
    2. Identify conflicting operations
    3. Draw directed edges
    1. A.

      2 then 3

    2. B.

      1 then 2

    3. C.

      3 then 1

    4. D.

      2 then 1

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: You cannot check for cycles or sort a graph that has not been constructed yet.

    Exam route: The checklist order is: 1. Identify conflicts, 2. Draw edges, 3. Check for cycles. The first two steps are 2 then 3 (Identify conflicts, then Draw edges).

    Learning route: To test conflict serializability, you must first find the raw material (conflicting operations). Only after identifying them can you draw the directed edges between transactions. Checking for cycles is the third step, performed after the graph is fully drawn. Thus, the correct chronological order of the first two steps is 2 then 3.

    Answer: 2 then 3

    Question 3 · Databases MCQ

    In the conflict serializability checklist, what is the immediate next step after confirming that the precedence graph has no cycles?

    1. A.

      Identify all conflicting operations

    2. B.

      Draw directed edges between transactions

    3. C.

      Use topological sorting to find the equivalent serial schedule

    4. D.

      Check for read-read illusions

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: The checklist follows a strict logical sequence: find conflicts build graph check cycles find equivalent schedule.

    Exam route: After step 3 (Check for Cycles) confirms the graph is acyclic, step 4 is to use topological sorting to find the equivalent serial schedule.

    Learning route: The conflict serializability checklist is a sequential algorithm:

    1. Identify Conflicts: Find pairs from different transactions accessing the same item with at least one write.
    2. Draw Edges: Create directed edges based on chronological order.
    3. Check for Cycles: If a cycle exists, it is not conflict serializable. If no cycle exists, it is conflict serializable.
    4. Find Equivalent Schedule: If acyclic, perform topological sorting on the graph to determine the valid equivalent serial schedule(s).

    Therefore, the step immediately following "no cycles" is topological sorting.

    Answer: Use topological sorting to find the equivalent serial schedule

    Question 4 · Databases NAT

    Consider the schedule . When constructing the precedence graph for conflict serializability, how many distinct directed edges are drawn between the transaction nodes?

    Correct Answer:

    2.00

    Step-by-Step Solution

    Key idea: this is a direct application of the precedence graph construction method.

    Step 1: Identify all conflicting pairs of operations.

    • and : Conflict (Read-Write). before . Edge: .
    • and : Conflict (Read-Write). before . Edge: .
    • and : Conflict (Write-Write). before . Edge: .

    Step 2: List the distinct directed edges.

    Step 3: Count the distinct edges.

    There are exactly 2 distinct directed edges.

    Answer: 2.00

    Question 5 · Databases MCQ

    A database management system provides four mandatory guarantees for every transaction. If a transaction successfully commits, its changes are permanent and will survive any subsequent system failure, power loss, or crash. This specific guarantee is known as:

    1. A.

      Atomicity

    2. B.

      Consistency

    3. C.

      Isolation

    4. D.

      Durability

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: The question describes the permanence of changes after a commit, even in the event of a crash.

    Step 1: Recall the ACID properties.

    Step 2: Match the description to the correct property. 'Permanent after commit' and 'survive system failure' are the exact definitions of Durability.

    Step 3: Atomicity is all-or-nothing, Consistency is preserving rules, Isolation is preventing interference.

    Answer: Durability.

    Question 6 · Databases MCQ

    Two operations from different transactions access the exact same data item. According to the core rule of conflicting operations, what is the maximum number of write operations that can be present in this pair such that the pair is guaranteed to NEVER conflict?

    1. A.

      0

    2. B.

      1

    3. C.

      2

    4. D.

      It depends on the read operations

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: The core rule of conflicting operations states that at least one operation must be a write for a conflict to occur.

    Step 1: Recall the three conditions for a conflict: different transactions, same data item, and at least one write.

    Step 2: The question asks for the maximum number of writes in a pair that will NEVER conflict.

    Step 3: If there is 1 write (Read-Write or Write-Read), it conflicts. If there are 2 writes (Write-Write), it conflicts.

    Step 4: The only way to guarantee NO conflict is to have 0 writes (Read-Read).

    Answer: 0.

    Question 7 · Databases MCQ

    Consider the following statements about a conflict serializable schedule :

    Statement 1: is guaranteed to be free of concurrency anomalies like Lost Updates.

    Statement 2: must be conflict equivalent to every possible serial schedule of its transactions.

    Which of the statements is/are true?

    1. A.

      Statement 1 only

    2. B.

      Statement 2 only

    3. C.

      Both Statement 1 and Statement 2

    4. D.

      Neither Statement 1 nor Statement 2

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: Conflict serializability guarantees equivalence to SOME serial schedule, not EVERY serial schedule.

    Step 1: Evaluate Statement 1. A conflict serializable schedule is guaranteed to produce the same result as a serial schedule, meaning it is free of concurrency anomalies like Lost Updates. Statement 1 is true.

    Step 2: Evaluate Statement 2. The definition states that must be conflict equivalent to SOME serial schedule. Different serial schedules (e.g., vs ) produce different final states if there are conflicting writes. can only be equivalent to one specific order, not every possible order. Statement 2 is false.

    Answer: Statement 1 only.

    Question 8 · Databases MCQ

    Match the following operation sequence with the correct edge drawn in the precedence graph.

    Sequence: occurs before

    1. A.

    2. B.

    3. C.

      No edge

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: Precedence graph edges always point from the transaction that performs the first conflicting operation to the transaction that performs the second.

    Exam route: The schedule has before . This is a Write-Read conflict. The edge must point from to .

    Learning route: Two operations conflict if they are from different transactions, access the same data item, and at least one is a write. Here, and conflict. Since appears chronologically before , the dependency is that must precede . Therefore, we draw a directed edge .

    Answer:

    Question 9 · Databases MCQ

    Match the following schedule with the correct set of directed edges in its precedence graph.

    Schedule:

    1. A.

    2. B.

    3. C.

      and

    4. D.

      No edges

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: Precedence graph edges are drawn for every pair of conflicting operations, pointing from the earlier transaction to the later one.

    Exam route: On , precedes , creating . On , precedes , creating . Both edges exist.

    Learning route: We analyze the schedule data item by data item.

    Step 1: For data item , and conflict (Write-Read). Since acts before , we draw .

    Step 2: For data item , and conflict (Write-Read). Since acts before , we draw .

    Step 3: Combine the edges. The precedence graph contains both and (which forms a cycle, meaning it is not conflict serializable, but the question only asks for the edges).

    Answer: and

    Question 10 · Databases MCQ

    Match the following schedule with the correct set of directed edges in its precedence graph.

    Schedule:

    1. A.

      and

    2. B.

      only

    3. C.

      only

    4. D.

      No edges

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is a conflict identification question requiring you to check each data item for cross-transaction conflicts.

    Step 1: Analyze data item . The schedule has followed by . This is a Write-Write conflict between different transactions. Since acts first, draw edge .

    Step 2: Analyze data item . The schedule has followed by . This is a Read-Read pair. Read-Read operations never conflict, so no edge is drawn for .

    Step 3: Combine the edges. The only edge in the graph is .

    Answer: only

    More notes in this unit