transaction management-database management system

SheebaS25 16 views 30 slides Oct 20, 2024
Slide 1
Slide 1 of 30
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30

About This Presentation

transaction management


Slide Content

Complete schedule: It is a schedule of transactions where each transaction is committed before terminating. The example is shown below where transactions T1 and T2 terminates after committing the transactions. Example : T1 T2 A=1000   Read(A)   A=A+100   Write(A) Read(A)   B=A-100   Write(B)   Commit Read(B)   Write(B)   Commit  

Serializability Serializability of schedules  ensures that a non-serial schedule is equivalent to a serial schedule . It helps in maintaining the transactions to execute simultaneously without interleaving one another.

Schedules in DBMS are of two types: Serial Schedule  - A schedule in which only one transaction is executed at a time, i.e., one transaction is executed completely before starting another transaction.

Example Transaction-1 Transaction-2 R(a) W(a) R(b) W(b) R(b) W(b) R(a) W(a)

Non-serial Schedule  - A schedule in which the transactions are interleaving or interchanging. There are several transactions executing simultaneously as they are being used in performing real-world database operations. These transactions may be working on the same piece of data. Hence, the serializability of non-serial schedules is a major concern so that our database is consistent before and after the execution of the transactions.

Example Transaction-1 Transaction-2 R(a) W(a) R(b) W(b) R(b) R(a) W(b) W(a)

Anomalies due to interleave execution of transaction: Anomalies due to Interleaved execution • There are three main situations when the actions of two transactions T1 and T2 conflict with each other in the interleaved execution on the same data object. Write-Read (WR) Conflict: Reading Uncommitted data. Read-Write (RW) Conflict: Unrepeatable Reads Write-Write (WW) Conflict: Overwriting Uncommitted Data

Reading uncommitted values(WR conflicts): If you try to the read the value which is not written on to the data base(not committed) will leads to write-read conflict which is called dirty read operation.

Un repeatable reading data operation(RW conflicts):   Reading the same object twice before committing the transaction might yield an inconsistency   –Read-then-Write (RW) Conflicts (Write-After-Read)   Unrepeatable problem means we get different values in different reads. For example in S1 say T2 read initially x=5 then T1 updated x=1 so now T2 will read x=1 here T2 has read two different values during consecutive reads This shouldn't have been allowed as T1 has not committed

Overwriting uncommitted data(WW conflicts)   WW conflicts if one transaction could over write the value of an object A which has been already modified by other transaction T1 while first transaction still in progress .This kind of conflict refer to blind write conflict.

Lock-Based Concurrency Control Locking is a concurrent control technique used to ensure serializability. • There are two types of locks. A transaction needs to acquire a lock before performing a transaction. • The read lock is known as shared lock and write lock is known as exclusive lock. • A locking protocol is a set of rules that a transaction follows to attain serializability

Strict Two-Phase Locking (Strict 2PL) Protocol The Strict 2PL has the following two rules: Rule 1: A transaction can read data only when it acquires a shared lock and can write data only when it acquires an exclusive lock on object. Rule 2: A transaction should release the locks when it is completed .

C oncurrency C ontrol T echniques are Two-phase locking Protocol Time stamp ordering Protocol Multi version concurrency control Validation concurrency control

Two Phase Locking Locking is an operation which secures: permission to read, OR permission to write a data item. Two phase locking is a process used to gain ownership of shared resources without creating the possibility of deadlock. The 3 activities taking place in the two phase update algorithm are: ( i ) Lock Acquisition (ii) Modification of Data (iii) Release Lock

Cont.. Two phase locking prevents deadlock from occurring in distributed systems by releasing all the resources it has acquired, if it is not possible to acquire all the resources required without waiting for another process to finish using a lock. This means that no process is ever in a state where it is holding some shared resources, and waiting for another process to release a shared resource which it requires. This means that deadlock cannot occur due to resource contention. A transaction in the Two Phase Locking Protocol can assume one of the 2 phases:

Cont.. Growing Phase:  In this phase a transaction can only acquire locks but cannot release any lock. The point when a transaction acquires all the locks it needs is called the Lock Point. Shrinking Phase:  In this phase a transaction can only release locks but cannot acquire any.

Time Stamp Ordering A timestamp is a tag that can be attached to any transaction or any data item, which denotes a specific time on which the transaction or the data item had been used in any way. A timestamp can be implemented in 2 ways. One is to directly assign the current value of the clock to the transaction or data item. The other is to attach the value of a logical counter that keeps increment as new timestamps are required. The timestamp of a data item can be of 2 types: ( i ) W-timestamp(X):  This means the latest time when the data item X has been written into. (ii) R-timestamp(X):  This means the latest time when the data item X has been read from. These 2 timestamps are updated each time a successful read/write operation is performed on the data item X.
Tags