2079 5

CSC265 · 2079 · 5 marks

What is conflict schedule? Explain with example.

What is conflict schedule? Explain with example. [5]

Database Management SystemChapter 8: Introduction to Transaction Processing Concepts and TheoryCharacterizing Schedules Based on Serializability

Quick answer

A conflict schedule (more precisely, a schedule with conflicting operations) refers to a schedule in which two or more transactions contain conflicting operations.

Conflict Schedule

Definition

A conflict schedule (more precisely, a schedule with conflicting operations) refers to a schedule in which two or more transactions contain conflicting operations. Two operations in a schedule are said to conflict if they satisfy all three of the following conditions:

  1. They belong to different transactions.
  2. They access the same data item X.
  3. At least one of them is a write operation.

The possible conflicting pairs are:

Operation PairConflict?
Read(X) and Read(X)No
Read(X) and Write(X)Yes
Write(X) and Read(X)Yes
Write(X) and Write(X)Yes

Conflict Serializability

A schedule is called conflict serializable if it can be transformed into a serial schedule by swapping non-conflicting operations. To test this, a precedence graph (serialization graph) is constructed.

Algorithm (from notes):

  1. Look at only read_Item(X) and write_Item(X) operations.
  2. Construct a precedence graph with directed edges.
  3. Draw an edge from Ti → Tj if an operation in Ti appears before a conflicting operation in Tj.
  4. The schedule is conflict serializable if and only if the precedence graph has no cycles.

Example

Consider two transactions:

  • T1: read(X), write(X), read(Y), write(Y)
  • T2: read(X), write(X), read(Y), write(Y)

Schedule S:

StepOperation
1T1: read(X)
2T2: read(X)
3T1: write(X)
4T2: write(X)
5T1: read(Y)
6T2: read(Y)
7T1: write(Y)
8T2: write(Y)

Identifying Conflicts:

Every pair below is on the same data item, from different transactions, with at least one write, so each pair contributes an edge in the direction of the operation that comes first in the schedule.

ConflictReason
T1:read(X) at step 1 and T2:write(X) at step 4T1 reads X before T2 writes it → T1 → T2
T2:read(X) at step 2 and T1:write(X) at step 3T2 reads X before T1 writes it → T2 → T1
T1:write(X) at step 3 and T2:write(X) at step 4Both write X, T1 first → T1 → T2
T1:read(Y) at step 5 and T2:write(Y) at step 8T1 reads Y before T2 writes it → T1 → T2
T2:read(Y) at step 6 and T1:write(Y) at step 7T2 reads Y before T1 writes it → T2 → T1
T1:write(Y) at step 7 and T2:write(Y) at step 8Both write Y, T1 first → T1 → T2

Precedence Graph:

T1 ---------> T2
 ^            |
 |____________|
  • Edges run in both directions, so the graph contains a cycle (T1 → T2 → T1).
  • Therefore, Schedule S is NOT conflict serializable. Neither serial order works: T2 reads X before T1 writes it, which would put T2 first, while T1 writes X before T2 writes it, which would put T1 first.

A Conflict Serializable Schedule S1:

Interleaving the same two transactions differently gives a schedule that is conflict serializable.

StepOperation
1T1: read(X)
2T1: write(X)
3T2: read(X)
4T1: read(Y)
5T2: write(X)
6T1: write(Y)
7T2: read(Y)
8T2: write(Y)

Here every conflicting pair has the T1 operation first: read(X) of T1 before write(X) of T2, write(X) of T1 before both read(X) and write(X) of T2, read(Y) of T1 before write(Y) of T2, and write(Y) of T1 before both read(Y) and write(Y) of T2.

Precedence Graph:

T1 ---------> T2
  • There is no cycle in this precedence graph.
  • Therefore, Schedule S1 is conflict serializable, equivalent to the serial schedule T1 → T2, even though its operations are interleaved.

Example of a NON-Conflict Serializable Schedule

Schedule S2:

StepOperation
1T1: read(X)
2T2: write(X)
3T1: write(X)
4T2: read(Y)
5T1: write(Y)
6T2: write(Y)

Conflicts:

  • T2:write(X) before T1:write(X) → T2 → T1
  • T1:write(Y) before T2:write(Y) → T1 → T2

Precedence Graph:

T1 ---------> T2
 ^            |
 |____________|
  • There is a cycle (T1 → T2 → T1).
  • Therefore, Schedule S2 is NOT conflict serializable.

Summary

A conflict schedule contains conflicting operations (same data item, different transactions, at least one write). It is conflict serializable if its precedence graph contains no cycle, meaning it is equivalent to some serial execution of the transactions.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.