0% found this document useful (0 votes)
45 views67 pages

ADMS - Chapter Five

The document discusses transaction processing concepts including transactions, concurrency control, and recovery. A transaction represents a logical unit of work that must be completed fully or not at all. The document covers transaction states, concurrency issues like lost updates, and the need for recovery from failures during transaction processing.

Uploaded by

Ataklti Teka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views67 pages

ADMS - Chapter Five

The document discusses transaction processing concepts including transactions, concurrency control, and recovery. A transaction represents a logical unit of work that must be completed fully or not at all. The document covers transaction states, concurrency issues like lost updates, and the need for recovery from failures during transaction processing.

Uploaded by

Ataklti Teka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 67

COSC 266

ADVANCED DATABASE MANAGEMENT


SYSTEM

Instructor : Getaneh Tilahun


Chapter 5

Transaction Processing
Concepts

CoSc 266 : Advanced Database management System


Instructor : Getaneh Tilahun
CHAPTER 5 OUTLINE
1. Introduction to Transaction Processing
2. Transaction and System Concepts
3. Desirable Properties of Transactions
4. Schedules and Recoverability
5. Serializability of Schedules
5.1 INTRODUCTION TO TRANSACTION PROCESSING
• Transaction: An executing program (process) that
includes one or more database access operations
– Read operations (database retrieval, such as SQL SELECT)
– Write operations (modify database, such as SQL INSERT,
UPDATE, DELETE)
– Transaction: A logical unit of database processing
– Example: Bank balance transfer of $100 dollars from a
checking account to a saving account in a BANK database
• Note: Each execution of a program is a distinct transaction
with different parameters
– Bank transfer program parameters: savings account
number, checking account number, transfer amount
INTRODUCTION TO TRANSACTION PROCESSING
• A transaction (set of operations) may be:
–stand-alone, specified in a high level language like
SQL submitted interactively, or
– consist of database operations embedded within a
program (most transactions)
• Transaction boundaries: Begin and End
transaction.
– Note: An application program may contain several
transactions separated by Begin and End transaction
boundaries
INTRODUCTION TO TRANSACTION PROCESSING (CONT.)
 Transaction Processing Systems
 Single-User System:
 At most one user at a time can use the system.

 Multiuser System:
 Many users can access the system concurrently.

• Two Modes of Concurrency


– Interleaved processing: concurrent execution of
processes is interleaved in a single CPU
– Parallel processing: processes are concurrently
executed in multiple CPUs
– Basic transaction processing theory assumes
interleaved concurrency
INTRODUCTION TO TRANSACTION PROCESSING
Types of Transaction
 Read-only transaction: A transaction operation that do not update
the database but only retrieve data from the database.

 Read-Write transaction: A transaction operation that perform the


update operation in addition to retrieval of database data.
For transaction processing purposes, a simple database model is used:
• A database - collection of named data items
• Granularity (size) of a data item - a field (data item value), a record,
or a whole disk block
– TP concepts are independent of granularity
• Basic operations on an item X:
– read_item(X): Reads a database item named X into a program
variable. To simplify our notation, we assume that the program
variable is also named X.
– write_item(X): Writes the value of program variable X into the
database item named X.
INTRODUCTION TO TRANSACTION PROCESSING
READ AND WRITE OPERATIONS:
 Basic unit of data transfer from the disk to the computer
main memory is one disk block (or page).
 A data item X (what is read or written) will usually be
the field of some record in the database, although it
may be a larger unit such as a whole record or even a
whole block.
 read_item(X) command includes the following
steps:
1. Find the address of the disk block that contains item X.

2. Copy that disk block into a buffer in main memory (if that disk block is
not already in some main memory buffer).

3. Copy item X from the buffer to the program variable named X.


INTRODUCTION TO TRANSACTION PROCESSING
READ AND WRITE OPERATIONS (cont.):
 write_item(X) command includes the following
steps:
1. Find the address of the disk block that contains item X.

2. Copy that disk block into a buffer in main memory (if it is


not already in some main memory buffer).

3. Copy item X from the program variable named X into its


correct location in the buffer.

4. Store the updated block from the buffer back to disk


(either immediately or at some later point in time).
TRANSACTION NOTATION

• Two simple examples of transactions.


• Can also write in shorthand notation:
– T1: b1; r1(X); w1(X); r1(Y); w1(Y); e1;
– T2: b2; r2(X); w2(X); e2;
• bi and ei specify transaction boundaries (begin and
end)
• i specifies a unique transaction identifier (TId)
WHY WE NEED CONCURRENCY CONTROL
Without Concurrency Control, problems may
occur with concurrent transactions:
1. Lost Update Problem.
Occurs when two transactions update the same data
item, but both read the same original value before
update (see figure a in the next slide)
2. The Temporary Update (or Dirty Read) Problem.
This occurs when one transaction T1 updates a
database item X, which is accessed (read) by another
transaction T2; then T1 fails for some reason (see figure
b in the next slide); X was (read) by T2 before its value is
changed back (rolled back or UNDONE) after T1 fails
WHY WE NEED CONCURRENCY CONTROL
3. The Incorrect Summary Problem .
One transaction is calculating an aggregate summary
function on a number of records (for example, sum
(total) of all bank account balances) while other
transactions are updating some of these records

For example, transferring a large amount between two


accounts, (see figure c in the next slide ); the
aggregate function may read some values before
they are updated and others after they are updated.
WHY WE NEED CONCURRENCY CONTROL?
4. The Unrepeatable Read Problem .
A transaction T1 may read an item (say, available seats
on a flight); later, T1 may read the same item again and
get a different value because another transaction T2 has
updated the item (reserved seats on the flight) between
the two reads by T1
Fro example
during an airline reservation transaction, a customer
inquires about seat availability on several flights. When
the customer decides on a particular flight, the
transaction then reads the number of seats on that flight
a second time before completing the reservation, and it
may end up reading a different value for the item.
WHY RECOVERY IS NEEDED?
 Whenever a transaction is submitted to a DBMS for
execution,
 The system is responsible for making sure that either all
the operations in the transaction are completed
successfully and their effect is recorded permanently in
the database, or that the transaction does not have any
effect on the database or any other transactions.
 In the first case, the transaction is said to be committed,
whereas in the second case, the transaction is aborted.
 If the transaction is aborted, there is failure. The
operations already executed must be undone and have
no lasting effect.
WHY RECOVERY IS NEEDED?
Causes of transaction failure:
1. A computer failure (system crash):
A hardware or software error occurs during transaction execution. If the hardware
crashes, the contents of the computer’s internal main memory may be lost.

2. A transaction or system error :


Some operation in the transaction may cause it to fail, such as integer
overflow or division by zero. Transaction failure may also occur because
of erroneous parameter values or because of a logical programming error.
In addition, the user may interrupt the transaction during its execution.
WHY RECOVERY IS NEEDED (CONT.)
3. Local errors or exception conditions detected by the
transaction:
certain conditions necessitate cancellation of the transaction.
For example, data for the transaction may not be found. A
condition, such as insufficient account balance in a banking
database, may cause a transaction, such as a fund withdrawal,
to be canceled - a programmed abort causes the transaction to
fail.
4. Concurrency control enforcement:
The concurrency control method may decide to abort the transaction, to be
restarted later, because it violates serializability or because several transactions are
in a state of deadlock
WHY RECOVERY IS NEEDED (CONT.)
5. Disk failure:
Some disk blocks may lose their data because of a read or write
malfunction or because of a disk read/write head crash. This kind
of failure and item 6 are more severe than items 1 through 4.

6. Physical problems and catastrophes:


This refers to an endless list of problems that includes power or
air-conditioning failure, fire, theft, sabotage, overwriting disks
or tapes by mistake, and mounting of a wrong tape by the
operator.
WHY RECOVERY IS NEEDED (CONT.)
 Failures of types 1, 2, 3, and 4 are more common than those
of types 5 or 6. Whenever a failure of type 1 through 4 occurs,
the system must keep sufficient information to quickly
recover from the failure.

 Disk failure or other catastrophic failures of type 5 or 6 do not


happen frequently; if they do occur, recovery is a major task.

(We discuss recovery from failure in Chapter 6).


5.2 TRANSACTION AND SYSTEM CONCEPTS
A transaction is an atomic unit of work that is either completed
in its entirety or not done at all.
For recovery purposes, the system needs to keep track of when each
transaction starts, terminates, and commits or aborts.

A transaction passes through several states (see figure in the next


slide).
Transaction states:
• Active state (executing read, write operations)
• Partially committed state (ended but waiting for system
checks to determine success or failure)
• Committed state (transaction succeeded)
• Failed state (transaction failed, must be rolled back)
• Terminated State (transaction leaves system)
TRANSACTION AND SYSTEM CONCEPTS
TRANSACTION AND SYSTEM CONCEPTS (CONT.)
DBMS Recovery Manager needs system to keep track of the
following operations (in the system log file):
• Begin_transaction: beginning of transaction execution.
• Read or write: Read or write operations on the database items
that are executed as part of a transaction.
• End_transaction: Specifies end of read and write transaction
operations have ended. System may still have to check whether
the changes (writes) introduced by transaction can be
permanently applied to the database (commit transaction); or
whether the transaction has to be rolled back (abort transaction)
because it violates concurrency control or for some other reason.
TRANSACTION AND SYSTEM CONCEPTS (CONT.)

Recovery manager keeps track of the following operations (cont:)

• Commit_transaction: Signals successful end of transaction; any


changes (writes) executed by transaction can be safely
committed to the database and will not be undone.

• Abort_transaction (or rollback): Signals transaction has ended


unsuccessfully; any changes or effects that the transaction may
have applied to the database must be undone.
TRANSACTION AND SYSTEM CONCEPTS (CONT.)

System operations used during recovery (will be covered


in chapter 6):

• undo(X): Similar to rollback except that it applies to a


single write operation rather than to a whole
transaction.

• redo(X): This specifies that a write operation of a


committed transaction must be redone to ensure that it
has been applied permanently to the database on disk.
TRANSACTION AND SYSTEM CONCEPTS (CONT.)
The System Log File
• Is an append-only file to keep track of all operations of all
transactions in the order in which they occurred. This information is
needed during recovery from failures
• Log is kept on disk - not affected except for disk or catastrophic
failure
• As with other disk files, a log main memory buffer is kept for
holding the records being appended until the whole buffer is
appended to the end of the log file on disk
• Log is periodically backed up to archival storage (tape) to guard
against catastrophic failures
TRANSACTION AND SYSTEM CONCEPTS (CONT.)
Types of records (entries) in log file:
• [start_transaction,T]: Records that transaction T has started
execution.
• [write_item,T,X,old_value,new_value]: T has changed the value of
item X from old_value to new_value.
• [read_item,T,X]: T has read the value of item X (not needed in
many cases).
• [end_transaction,T]: T has ended execution
• [commit,T]: T has completed successfully, and committed.
• [abort,T]: T has been aborted.
TRANSACTION AND SYSTEM CONCEPTS (CONT.)
The System Log (cont.):
 protocols for recovery that avoid cascading rollbacks
do not require that read operations be written to the
system log; most recovery protocols fall in this
category
 strict protocols require simpler write entries that do not
include new_value
TRANSACTION AND SYSTEM CONCEPTS (CONT.)
Commit Point of a Transaction:
 Definition: A transaction T reaches its commit point when
all its operations that access the database have been executed
successfully and the effect of all the transaction operations
on the database has been recorded in the log file (on disk).
The transaction is then said to be committed.
TRANSACTION AND SYSTEM CONCEPTS (CONT.)
Commit Point of a Transaction (cont.):
 Log file buffers: Like database files on disk, whole disk blocks must be
read or written to main memory buffers.

 For log file, the last disk block (or blocks) of the file will be in main
memory buffers to easily append log entries at end of file.

 Force writing the log buffer: before a transaction reaches its commit
point, any main memory buffers of the log that have not been written to
disk yet must be copied to disk.

 Called force-writing the log buffers before committing a transaction.

 Needed to ensure that any write operations by the transaction are recorded
in the log file on disk before the transaction commits
5.3 DESIRABLE PROPERTIES OF TRANSACTIONS

Transactions should possess several properties, often called


the ACID properties – Atomicity, Consistency, Isolation,
Durability:
• Atomicity: A transaction is an atomic unit of processing; it
is either performed in its entirety or not performed at all.

• Consistency preservation: A correct execution of the


transaction must take the database from one consistent state
to another.
DESIRABLE PROPERTIES OF TRANSACTIONS (CONT.)

ACID properties (cont.):


• Isolation: Even though transactions are executing concurrently,
they should appear to be executed in isolation – that is, their
final effect should be as if each transaction was executed in
isolation from start to finish.

• Durability or permanency: Once a transaction is committed,


its changes (writes) applied to the database must never be lost
because of subsequent failure.
DESIRABLE PROPERTIES OF TRANSACTIONS (CONT.)
• Atomicity: Enforced by the recovery protocol. It is the
responsibility of the transaction recovery subsystem of a DBMS to
ensure atomicity

• Consistency preservation: Specifies that each transaction does a


correct action on the database on its own. Application programmers
and DBMS constraint enforcement are responsible for this.

• Isolation: Responsibility of the concurrency control protocol.

• Durability or permanency: Enforced by the recovery protocol.


SCHEDULES OF TRANSACTIONS
• Transaction schedule (or history): When transactions are
executing concurrently in an interleaved fashion, the order of
execution of operations from the various transactions forms
what is known as a transaction schedule (or history).

• Figure in the next slide shows 4 possible schedules (A, B, C, D)


of two transactions T1 and T2:
– Order of operations from top to bottom
– Each schedule includes same operations
– Different order of operations in each schedule
SCHEDULES OF TRANSACTIONS (CONT.)
• Schedules can also be displayed in more compact
notation
• Order of operations from left to right
• Include only read (r) and write (w) operations, with
transaction id (1, 2, …) and item name (X, Y, …)
• Can also include other operations such as b (begin), e
(end), c (commit), a (abort)
• Schedules in the figure above slide would be displayed
as follows:
– Schedule A: r1(X); w1(X); r1(Y); w1(Y); r2(X); w2(x);

– Schedule B: r2(X); w2(X); r1(X); w1(X); r1(Y); w1(Y);

– Schedule C: r1(X); r2(X); w1(X); r1(Y); w2(X); w1(Y);

– Schedule D: r1(X); w1(X); r2(X); w2(X); r1(Y); w1(Y);


SCHEDULES OF TRANSACTIONS (CONT.)
• Formal definition of a schedule (or history) S of n
transactions T1, T2, ..., Tn :
An ordering of all the operations of the transactions
subject to the constraint that, for each transaction Ti
that participates in S, the operations of Ti in S must
appear in the same order in which they occur in Ti.

Note: Operations from other transactions T j can be


interleaved with the operations of Ti in S.
SCHEDULES OF TRANSACTIONS (CONT.)
Conflict of Schedule
• 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 item X and
3. At least one of the operations is a write_item(X).

Sa: r1(X); r2(X); w1(X); r1(Y); w2(X); w1(Y);


For example, In schedule Sa, the operations
 r1(X) and w2(X) , r2(X) and w1(X), and w1(X) and w2(X) are
conflict schedule.
However,
 r1(X) and r2(X) do not conflict, since they are both read
operations;
 w2(X) and w1(Y) do not conflict because they operate on
distinct data items X and Y; and
 r1(X) and w1(X) do not conflict because they belong to the
same transaction.
SCHEDULES OF TRANSACTIONS (CONT.)
• The rest of this section covers some theoretical definitions
concerning schedules.
• A schedule S of n transactions T1, T2, ..., Tn is said to be a
complete schedule if the following conditions hold:
1. The operations in S are exactly those operations in T1,T2,...,Tn,
including a commit or abort operation as the last operation for each
transaction in the schedule.
2. For any pair of operations from the same transaction Ti, their relative
order of appearance in S is the same as their order of appearance in Ti.
3. For any two conflicting operations, one of the two must occur before
the other in the schedule.
• Rest of chapter characterizes schedules by classifying them based
on ease of recovery (recoverability) and correctness
(serializability)
5.4 CHARACTERIZING SCHEDULES BASED
ON RECOVERABILITY
Schedules classified into two main classes:
• Recoverable schedule: One where no committed transaction
needs to be rolled back (aborted).
A schedule S is recoverable if no transaction T in S commits until all
transactions T’ that have written an item that T reads have committed.

• Non-recoverable schedule: A schedule where a committed


transaction may have to be rolled back during recovery.
This violates Durability from ACID properties (a committed
transaction cannot be rolled back) and so non-recoverable schedules
should not be allowed.
CHARACTERIZING SCHEDULES BASED ON
RECOVERABILITY (CONT.)
• Example: Schedule A below is non-recoverable
because T2 reads the value of X that was written by T1,
but then T2 commits before T1 commits or aborts
• To make it recoverable, the commit of T2 (c2) must be
delayed until T1 either commits, or aborts (Schedule B)
• If T1 commits, T2 can commit
• If T1 aborts, T2 must also abort because it read a value
that was written by T1; this value must be undone
(reset to its old value) when T1 is aborted
– known as cascading rollback

• Schedule A: r1(X); w1(X); r2(X); w2(X); c2; r1(Y); w1(Y); c1 (or a1)
• Schedule B: r1(X); w1(X); r2(X); w2(X); r1(Y); w1(Y); c1 (or a1); ...
CHARACTERIZING SCHEDULES BASED ON
RECOVERABILITY (CONT.)
Recoverable schedules can be further
refined:
• Cascadeless schedule: A schedule in which a
transaction T2 cannot read an item X until the
transaction T1 that last wrote X has committed.
• The set of cascadeless schedules is a subset of the set
of recoverable schedules.

Schedules requiring cascaded rollback: A


schedule in which an uncommitted transaction T2
that read an item that was written by a failed
transaction T1 must be rolled back.
CHARACTERIZING SCHEDULES BASED
ON RECOVERABILITY (CONT.)
• Example: Schedule B below is not cascadeless
because T2 reads the value of X that was written by
T1 before T1 commits
• If T1 aborts (fails), T2 must also be aborted (rolled
back) resulting in cascading rollback
• To make it cascadeless, the r2(X) of T2 must be
delayed until T1 commits (or aborts and rolls back the
value of X to its previous value) – see Schedule C

• Schedule B: r1(X); w1(X); r2(X); w2(X); r1(Y); w1(Y); c1 (or a1);


• Schedule C: r1(X); w1(X); r1(Y); w1(Y); c1; r2(X); w2(X); ...
CHARACTERIZING SCHEDULES BASED
ON RECOVERABILITY (CONT.)
Cascadeless schedules can be further refined:
• Strict schedule: A schedule in which a
transaction T2 can neither read nor write an item X
until the transaction T1 that last wrote X has
committed.
• The set of strict schedules is a subset of the set of
cascadeless schedules.
• If blind writes are not allowed, all cascadeless
schedules are also strict

Blind write: A write operation w2(X) that is not


preceded by a read r2(X).
CHARACTERIZING SCHEDULES BASED
ON RECOVERABILITY (CONT.)
• Example: Schedule C below is cascadeless and also
strict (because it has no blind writes)
• Schedule D is cascadeless, but not strict (because of
the blind write w3(X), which writes the value of X
before T1 commits)
• To make it strict, w3(X) must be delayed until after
T1 commits – see Schedule E

• Schedule C: r1(X); w1(X); r1(Y); w1(Y); c1; r2(X); w2(X); …


• Schedule D: r1(X); w1(X); w3(X); r1(Y); w1(Y); c1; r2(X); w2(X); …
• Schedule E: r1(X); w1(X); r1(Y); w1(Y); c1; w3(X); r2(X); w2(X); …
CHARACTERIZING SCHEDULES BASED
ON RECOVERABILITY (CONT.)
Summary:
• Many schedules can exist for a set of transactions
• The set of all possible schedules can be partitioned
into two subsets: recoverable and non-recoverable
• A subset of the recoverable schedules are
cascadeless
• If blind writes are allowed, a subset of the cascadeless
schedules are not strict
• If blind writes are not allowed, the set of cascadeless
schedules is the same as the set of strict schedules
5.5 CHARACTERIZING SCHEDULES
BASED ON SERIALIZABILITY
• Among the large set of possible schedules, we
want to characterize which schedules are
guaranteed to give a correct result
• The consistency preservation property of the
ACID properties states that: each transaction if
executed on its own (from start to finish) will
transform a consistent state of the database into
another consistent state
• Hence, each transaction is correct on its own
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
• Serial schedule: A schedule S is serial if, for
every transaction T participating in the schedule,
all the operations of T are executed consecutively
(without interleaving of operations from other
transactions) in the schedule. Otherwise, the
schedule is called non-serial. (see the figure in the
next slide)

• Based on the consistency preservation property,


any serial schedule will produce a correct result
(assuming no inter-dependencies among different
transactions)
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
CHARACTERIZING SCHEDULES BASED
ON SERIALIZABILITY (CONT.)
 If the schedule is a serial one and if no interleaving
of operations is permitted, there are only two
possible outcomes:
1. Execute all the operations of transaction T1 (in
sequence) followed by all the operations of transaction
T2 (in sequence).
2. Execute all the operations of transaction T2 (in
sequence) followed by all the operations of transaction
T1 (in sequence).
 These two schedules—called serial schedules—are shown in
Figure (a) and (b) above, respectively.
 If interleaving of operations is allowed, there will be
many possible orders in which the system can execute
the individual operations of the transactions.
CHARACTERIZING SCHEDULES BASED
ON SERIALIZABILITY (CONT.)
• Serial schedules are not feasible for performance
reasons:
– No interleaving of operations
– Long transactions force other transactions to
wait
– System (CPU) cannot switch to other
transaction when a transaction is waiting for
disk I/O or any other event, thus wasting
valuable CPU processing time
 Need to allow concurrency with interleaving
without sacrificing correctness
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
• Serializability of schedules
 The concept of serializability of schedules is used to identify
which schedules are correct when transaction executions
have interleaving of their operations in the schedules.
• Serializable schedule: A schedule S is serializable
if it is equivalent to some serial schedule of the same
n transactions.
• There are (n)! serial schedules for n transactions – a
serializable schedule can be equivalent to any of the
serial schedules.
• The objective is to determine which of the nonserial
schedules always give a correct result and which may
give erroneous results
• Question: How do we define equivalence of schedules?
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
• Serializability of schedules
 A schedule S of n transactions is serializable if it is
equivalent to some serial schedule of the same n
transactions. In the figure bellow, a and b are serial
schedule but D is non serial schedule. a and d gives the
same result
EQUIVALENCE OF SCHEDULES
• Result equivalent: Two schedules are called
result equivalent if they produce the same final
state of the database.
• Difficult to determine without analyzing the
internal operations of the transactions, which is not
feasible in general.
• May also get result equivalence by chance for a
particular input parameter even though schedules
are not equivalent in general
EQUIVALENCE OF SCHEDULES (CONT.)
• Conflict equivalent: Two schedules are conflict
equivalent if the relative order of any two conflicting
operations is the same in both schedules.
• Commonly used definition of schedule equivalence
• Two operations are conflicting if:
– They access the same data item X
– They are from two different transactions
– At least one is a write operation
• Read-Write conflict example: r1(X) and w2(X)
• Write-write conflict example: w1(Y) and w2(Y)
EQUIVALENCE OF SCHEDULES (CONT.)
• Changing the order of conflicting operations
generally causes a different outcome
• Example: changing r1(X); w2(X) to w2(X); r1(X)
means that T1 will read a different value for X
• Example: changing w1(Y); w2(Y) to w2(Y); w1(Y)
means that the final value for Y in the database
can be different
• Note that read operations are not conflicting;
changing r1(Z); r2(Z) to r2(Z); r1(Z) does not
change the outcome
CHARACTERIZING SCEDULES BASED
ON SERIALIZABILITY (CONT.)

• Conflict equivalence of schedules is used to


determine which schedules are correct in general
(serializable)

A schedule S is said to be serializable if it is


conflict equivalent to some serial schedule S’.
CHARACTERIZING SCHEDULES BASED
ON SERIALIZABILITY (CONT.)

• A serializable schedule is considered to be correct


because it is equivalent to a serial schedule, and any
serial schedule is considered to be correct
– It will leave the database in a consistent state.

– The interleaving is appropriate and will result in a state as


if the transactions were serially executed, yet will achieve
efficiency due to concurrent execution and interleaving of
operations from different transactions.
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
• Serializability is generally hard to check at run-time:
– Interleaving of operations is generally handled by the
operating system through the process scheduler
– Difficult to determine beforehand how the operations in a
schedule will be interleaved
– Transactions are continuously started and terminated
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
Practical approach:
• Come up with methods (concurrency control
protocols) to ensure serializability (discussed in
Chapter 6)
• DBMS concurrency control subsystem will
enforce the protocol rules and thus guarantee
serializability of schedules
• Current approach used in most DBMSs:
– Use of locks with two phase locking (see chpter 6)
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
Testing for conflict serializability
Algorithm
• Looks at only r(X) and w(X) operations in a schedule
• Constructs a precedence graph (serialization graph) –
one node for each transaction, plus directed edges
• An edge is created from Ti to Tj if one of the
operations in Ti appears before a conflicting operation
in Tj
• The schedule is serializable if and only if the
precedence graph has no cycles.
CHARACTERIZING SCHEDULES BASED ON
SERIALIZABILITY (CONT.)
END OF CHAPTER 5
THANK YOU!

You might also like