Unit 4 chapter - 8 Transaction processing Concepts (1).pptx

Unit – 4
Chapter - 8
Transaction Processing
Concepts
INTRODUCTION
• Transaction processing system are systems with large databases and hundreds of
concurrent users that are executing database transactions.
• EX: System for reservations, banking, Credit card processing, stock markets,
supermarket checkout, and other similar systems.
• They require high availability and fast response time for hundreds of concurrent
users.
• In this chapter we present the concepts that are needed in transaction processing
system.
Transaction Processing Concepts
Transaction
A transaction is the basic logical unit of execution in an information system. A
transaction is a sequence of operations that must be executed as a whole, taking a
consistent (correct) database state into another consistent (correct) database state.
A transaction is a discrete unit of work that must be completely processed (or) not
processed at all.
Ex: Transferring funds from a checking account to a saving account.
Transaction Processing System (TPS)
Transaction processing systems are systems with large databases and hundreds of
concurrent users that are executing database transactions.
Ex: Airline reservation system, Order entry/processing systems, Bank’s account
processing systems.
Characteristics of TPS are
• Large amounts of data are processed
• The TPS processes information on a regular basis: daily, weekly, monthly, etc
• Large storage (database) capacity is required
• High processing speed is needed due to the high volume
• TPS basically monitors and collects past data
• High reliability is required
Transactional processing systems provide three functional areas.
1. System runtime functions
• Transaction processing systems provide an execution environment that ensures
the integrity, availability, and security of data.
• It also ensures fast response time and high transaction throughput .
2. System administration functions
• Transaction processing systems provide administrative support that lets users
configure, monitor, and manage their transaction system.
3. Application development functions
• Transaction processing systems provide functions for use in custom business
applications, Including function to access data, to perform inter computer
communication etc.
Single – user vs. Multi – user System
Single-User System
• A DBMS is single-user if at most one user can use the system at a time.
• The basic components of a transaction processing system can be found in single
user systems.
• Single-user DBMSs are mostly restricted to personal computer systems.
• Presentation Services – displays forms, handles flow of information to/from
screen.
• Application Services – implements user request, interacts with DBMS.
Multi-User System
• A DBMS is multi-user if many users can use the system concurrently.
• In multi-user system, many users can use the system and hence access the
database-concurrently
• Dumb terminals connected to mainframe
Application and presentation services on mainframe.
• ACID properties required
Isolation: DBMS sees an interleaved schedule.
Atomicity and durability: System supports a major enterprise.
• Transaction abstraction, implemented by DBMS, provides ACID properties.
Transaction And Systems Concepts
Transaction Operations
• A transaction is an atomic unit of work that is either completed in its entirety or not
not done at all.
• For recovery purposes the system needs to keep track of when the transaction starts,
starts, terminates and commits (or) aborts.
The recovery manager keeps track of the following operations:
• Begin_transaction: marks the beginning of the transaction executes.
• Read (or) Write : Two possible operations on the data. These specify read or write
operations on the database items that are executed as part of a transaction.
• End_transaction: Specifies that operations have ended and marks the end of
execution. The change can be either committed or aborted.
Recovery techniques use the following operators:
• undo : similar to rollback except that it applies to a single operation rather than to a
whole transaction.
• redo : This specifies that certain transaction operations must be redone to ensure
that all the operations of a committed transaction have been applied successfully to
to the database.
Transaction States
A transaction is any one execution of a user program in a DBMS, a transaction moves
moves through various types of execution states.
• Active state – the initial state, The active state is the first state of every transaction.
In this state, the transaction is being executed.
• Partially committed state - In the partially committed state, a transaction
executes its final operation, but the data is still not saved to the database.
• Failed state – after the discovery that normal execution can no longer proceed
• Aborted state – after the transaction has been rolled backed and the database has
been restored to its state prior to the start od transaction.
• Committed state - A transaction is said to be in a committed state if it executes all
its operations successfully. In this state, all the effects are now permanently saved
on the database system.
System Log
• Log is nothing but a file which contains a sequence of records, each log record
refers to a write operation.
• All the log records are recorded step by step in the log file. We can say, log files store
store the history of all updates activities.
• This information may be needed to permit recovery from transaction failures.
• Log contains start of transaction, transaction number, record number, old value,
new value, end of transaction etc. For example, mini statements in bank ATMs.
• The log is kept on disk, so it is not affected by any type of failure except for disk (or)
(or) catastrophic failure.
• In addition, the log is periodically backed up to archival storage (tape) to guard
against such catastrophic failures.
• “ T ” in the following discussion refers to a unique transaction-id that is generated
generated automatically by the system and is used to identify each transaction.
Types of log records
• <Ti, Xi, V1, V2> − update log record,
where Ti=transaction, Xi=data, V1=old data, V2=new value.
• <Ti, start> − Transaction Ti starts execution.
• <Ti, commit> − Transaction Ti is committed.
• <Ti, abort> − Transaction Ti is aborted
 [start_transaction, T ] : Records that transaction T has started execution.
 [read_item, T, X] : Records that transaction T has read the value of database item
item X.
 [commit, T] : Records that transaction T has completed successfully.
 [abort, T] : Record that transaction T has been aborted.
Commit Point of a Transaction
A transaction T is said to reach its commit point only when it completes all its
operation that has actually accessed the database and have been executed
successfully and the effect of all transaction operation on the database have been
recorded in the log. The transaction then writes an entry [commit, T] into the log.
• Roll Back of transaction : to erase all data modifications made from the start of
the transaction or to a savepoint.
• Redoing transactions: Transactions that have written their commit entry in the
log must also have recorded all their write operations in the log, otherwise they
would not be committed, so their effect on the database can be redone from the log
log entries.
• Force writing a log: Before a transaction reaches its commit point, any portion of
the log that has not been written to the disk yet must now be written to the disk.
This process is called force-writing the log file before committing a transaction.
Desirable properties of Transaction
The transaction has the four properties . In order to maintain consistency in a
database, before and after the transaction. These are called ACID properties.
ACID properties are applied for maintaining the integrity of database during
transaction processing.
ACID stands for Atomicity, Consistency, Isolation, and Durability.
Atomicity
• It states that all operations of the transaction take place at once if not, the
transction is aborted.
• There is no midway, i.e., the transaction cannot occur partially. Each transaction is
is treated as one unit and either run to completion or is not executed at all.
Atomicity involves the following two operations:
Abort: if a transaction aborts then all the changes made are not visible.
Commit: if a transaction commits then all the changes made are visible.
Consistency
• The integrity constraint are maintained so that the database is consistent before
and after the transaction.
• The execution of transaction will leave a database in either its prior stable state or
or new stable state.
• The consistent property of database states that every transaction sees a consistent
consistent database instance.
• The transaction is used to transform the database from one consistent state to
another consistent state
Isolation
• It shows that the data which is used at the time of execution of a transaction cannot
cannot be used by the second transaction until the first one is completed.
• In isolation, if the transaction T1 is being executed and using the data item X, then
then that data item cant be accessed by any other transaction T2 until the
transaction T1 ends.
• The concurrency control subsystem of the DBMS enforced the isolation property.
property.
Durability
• guarantees that once a transaction is committed, its effects are permanent and
survive any system failures. Together, these properties ensure reliability and
maintain data integrity in DBMS operations.
(optional)
• Atomicity ensures that a transaction is treated as a single indivisible
unit, either executing all its operations or none at all.
• Consistency ensures that the database remains in a valid state before
and after a transaction.
• Isolation ensures that concurrent transactions do not interfere with
each other, maintaining data integrity.
• Durability guarantees that once a transaction is committed, its effects
are permanent and survive any system failures. Together, these
properties ensure reliability and maintain data integrity in DBMS
operations.
Transaction Support System in SQL
Transaction initiation is done implicitly when SQL statement is executed. Every
transaction must have explicit end statement, which is either commit or rollback.
Every transaction has certain characteristics:
• Access mode: read only (or) read write.
• Diagnostic area size: option specifies an integer value n, indicating the number of
conditions that can be held simultaneously in the diagnostic area.
(The diagnostics area contains two kinds of information:
 Statement information, such as the number of conditions that occurred or the affected-rows
count.
 Condition information, such as the error code and message.)
• The isolation level: option that can be read uncommitted, read committed,
repeatable read, serializable.
(serializable :ensures that multiple transactions can access and modify the same data without interfering with each
other’s operations.)
If a transaction executes at a lower isolation level than serializable, then one or
more of the following violations may occur.
Dirty read: Reading a value that was written by a transaction which failed.
Non repeatable read: Allowing another transaction to write a new value
multiple reads of one transaction.
Phantom: A transaction T1 may read a set of rows from a table, then another
transaction T2 inserts new rows. If T1 repeated, then it will see a Phantom.
(Phantom Read – Phantom Read occurs when two same queries are executed, but the rows
retrieved by the two, are different.
For example, suppose transaction T1 retrieves a set of rows that satisfy some search criteria. Now,
Transaction T2 generates some new rows that match the search criteria for transaction T1)
Concurrency Control Techniques
• Concurrency control is a database management systems(DBMS) concept that is
used to address conflicts with the simultaneous accessing or altering of data that
can occur with a multi-user system.
• Concurrency control, when applied to a DBMS, is meant to co-ordinate
simultaneous transactions while preserving data integrity. The concurrency is
about to control the multiuser access of database.
Purpose of Concurrency control
• enforce isolation among transactions.
• preserve database consistency through consistency preserving execution of transactions.
• resolve read-write and write-read conflicts.
Terms of Concurrency Control
Transaction: A transaction is an execution of a user program as a series of reads and writes
of database objects
Schedules: A schedule is the arrangement of transaction operations. A schedule may contain
a set of transactions (Reading, Writing, Aborting or committing)To run transactions
concurrently, we arrange or schedule their operations in an interleaved fashion.
Serializability: Serialization helps in checking concurrency control between multiple
transactions. It also helps in maintaining consistency in the database before and after any
transaction. Serializable schedules are resource-efficient and help in improving CPU
throughput
Or
Serializability of a schedule means equivalence to a serial schedule (i.e., sequential with no
transaction overlap in time) with the same transactions.
Locking System for Concurrency Control
Two operations lock item and unlock item are used with binary Locking
2. Shared / exclusive (or) read/Write locks
1. Shared lock:
• It is also known as a Read-only lock. In a shared lock, the data item can only read by
by the transaction.
• It can be shared between the transactions because when the transaction holds a lock,
lock, then it can't update the data on the data item.
2. Exclusive lock:
• In the exclusive lock, the data item can be both reads as well as written by the
transaction.
• This lock is exclusive, and in this lock, multiple transactions do not modify the same
same data simultaneously.
There are three locking operations:
1. read_lock(X)
2. Write_lock(X)
3. Unlock(X)
• There are three possible states read locked, write locked(or) unlocked.
1. A read locked item is also called shared-locked because outer transactions are
are allowed to read the item.
2. Write locked item is called exclusive-locked because a single transaction
exclusively holds the lock on the item.
3. To implement these three operations on a read/write lock is to keep of the
number of transactions that hold a shared(read) lock on an item in the lock
table.
• Shared/ Exclusive locking scheme, the system must enforce the following
rules:
• A transaction T must issue the operation read_lock(X) (or) before any read-
item(X) operation is performed on T
• A transaction T must issue the operation write_lock(X) before any write_item(X)
• A transaction T will not issue a read_lock(X) operation if it already holds a
read lock(or) a write lock in item X.
• A transaction T will not issue a write_lock(X) operation if it already holds a
read lock (or) write lock on item X.
Lock Conversion
Two phase Locking (2PL)
• The two-phase locking protocol divides the execution phase of the transaction into
three parts.
• In the first part, when the execution of the transaction starts, it seeks permission for
the lock it requires.
• In the second part, the transaction acquires all the locks. The third phase is started as
as soon as the transaction releases its first lock.
• In the third phase, the transaction cannot demand any new locks. It only releases the
the acquired locks.
Two-Phase Locking Techniques : Essential Components
1. Lock Manager: Managing locks on data items.
2. Lock Table: Lock manager uses it to store the identify of transaction locking a data
item, the data item, lock mode and pointer to the next data item locked. One simple
simple way to implement a lock table is through linked list.
• Database requires that all transactions should be well-formed.
• It must lock the data item before it reads or write to it.
There are two phases of 2PL:
• Growing phase: In the growing phase, a new lock on the data item may be acquired
by the transaction, but none can be released.
• Shrinking phase: In the shrinking phase, existing lock held by the transaction may
be released, but no new locks can be acquired.
Two Phase policy generates two locking algorithm (a) Basic and (b) Conservative.
• Conservative: Prevents deadlocks by locking all desired data items before
transaction begins execution.
• Basic: Transaction locks data items incrementally. This may cause deadlock which is
dealt with.
Problems caused by use of Locks
The use of locks, can cause two problems, they are
• Deadlock
• Starvation
Deadlock
• A system is in a deadlock state if there exists a set of transactions such that every
transaction in the set in waiting for another transaction in the set.
• A deadlock is a situation in which two computer programs sharing the same
resource are effectively preventing each other from accessing the resource, resulting
resulting in both programs ceasing function.
Ex: there exists a set of waiting transaction {T0, T1,……Tn} such that T0 is waiting for
for data item that is held by T1, T1 is waiting for a data item that is held by T2, Tn-1 is
1 is waiting for a data item that is held by Tn, and Tn is waiting for a data item that is
is held by T0. None of the transactions can make progress in such a situation.
Dealing with Deadlock and Starvation
Deadkock prevention
• A transaction locks all data items it refers to before it begins execution.
• This way of locking prevents deadlock since a transaction never waits for a data
item.
• The conservative two-locking uses this approach.
Deadlock detection and resolution
• In this approach, deadlocks are allowed to happen. The scheduler maintains a
wait-for-graph for detecting cycle. If a cycle exists, then one transaction involved
involved in then cycle is selected (victim) and roller-back.
• A wait-for-graph is created using the lock table. As soon as a transaction is
blocked, it is added to the graph. When a chain like: Ti waits for Tj waits for Tk
waits for Ti or Tj occurs, then this creates a cycle.
Deadlock avoidance
• There are many variations of two-phase locking algorithm.
• Some avoid deadlock by not letting the cycle to complete.
• That is as soon as the algorithm discovers that blocking a transaction is likely to
create a cycle, it rolls back the transaction.
Starvation
• Starvation occurs when a particular transaction consistently waits or restarted and
and never gets a chance to proceed further.
• In a deadlock resolution it is possible that the same transaction may consistently be
be selected as victim and rolled-back.
• The limitation is inherent in all priority based scheduling mechanisms.
• In wound-wait scheme a younger transaction may always be wounded (aborted) by
by a long running older transaction which may create starvation.
DeadLock Prevention
A deadlock can be prevented by following two commonly used schemes.
1. Wait – die
2. Wound-wait
Wait-die Scheme
(Non-Preemptive Scheduling is one in which once the resources
(CPU Cycle) have been allocated to a process, the process holds it
until it completes its burst time or switches to the 'wait' state.
In non-preemptive scheduling, a process cannot be interrupted
until it terminates itself or its time is over.)
(Preemptive Scheduling is a CPU scheduling technique that
works by dividing time slots of CPU to a given process.
The time slot given might be able to complete the whole process or
might not be able to it.)
2. Wound – Wait scheme
Deadlock detection
Recovery Techniques
Database recovery techniques are used in database management systems (DBMS)
(DBMS) to restore a database to a consistent state after a failure or error has
occurred. The main goal of recovery techniques is to ensure data integrity and
consistency and prevent data loss.
Failure Classification
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Recovery Techniques in DBMS
Concurrency Control Based on Time Stamp Ordering
• Timestamp TS(T) is a unique identifier created by DBMS to identify the
transaction
• The timestamp values are assigned in the order in which the transaction are
submitted to the system
• The timestamp can be generated using a counter that is incremented each time its
its value is assigned to a transaction
• Timestamp ordering algorithm (TO) it orders the transaction according to their
timestamps
• It generates serializability of schedules
• The algorithm must ensure that for each item accessed by conflicting operations in
in the schedule, does not violate the serializability order.
Database Backup and Recovery from Catastrophic Failures
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
Unit 4 chapter - 8 Transaction processing Concepts (1).pptx
1 de 47

Recomendados

Unit 4 dbms por
Unit 4 dbmsUnit 4 dbms
Unit 4 dbmsSweta Singh
39 vistas66 diapositivas
Presentation on Transaction por
Presentation on TransactionPresentation on Transaction
Presentation on TransactionRahul Prajapati
141 vistas21 diapositivas
transaction_processing.ppt por
transaction_processing.ppttransaction_processing.ppt
transaction_processing.pptNikhilKumarAgarwalK
2 vistas85 diapositivas
Transaction Processing Concept por
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing ConceptNishant Munjal
5.4K vistas26 diapositivas
What is Database Backup? The 3 Important Recovery Techniques from transaction... por
What is Database Backup? The 3 Important Recovery Techniques from transaction...What is Database Backup? The 3 Important Recovery Techniques from transaction...
What is Database Backup? The 3 Important Recovery Techniques from transaction...Raj vardhan
195 vistas6 diapositivas
Introduction to transaction management por
Introduction to transaction managementIntroduction to transaction management
Introduction to transaction managementDr. C.V. Suresh Babu
438 vistas18 diapositivas

Más contenido relacionado

Similar a Unit 4 chapter - 8 Transaction processing Concepts (1).pptx

DBMS UNIT IV.pptx por
DBMS UNIT IV.pptxDBMS UNIT IV.pptx
DBMS UNIT IV.pptxJanagi Raman S
118 vistas170 diapositivas
Transaction processing por
Transaction processingTransaction processing
Transaction processingSoumyajit Dutta
236 vistas40 diapositivas
DBMS Vardhaman.pdf por
DBMS Vardhaman.pdfDBMS Vardhaman.pdf
DBMS Vardhaman.pdfNithishReddy90
11 vistas43 diapositivas
Introduction to transaction processing concepts and theory por
Introduction to transaction processing concepts and theoryIntroduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theoryZainab Almugbel
2.2K vistas39 diapositivas
Autonomous transaction por
Autonomous transactionAutonomous transaction
Autonomous transactionRajeev Rastogi (KRR)
1.7K vistas25 diapositivas

Similar a Unit 4 chapter - 8 Transaction processing Concepts (1).pptx(20)

Introduction to transaction processing concepts and theory por Zainab Almugbel
Introduction to transaction processing concepts and theoryIntroduction to transaction processing concepts and theory
Introduction to transaction processing concepts and theory
Zainab Almugbel2.2K vistas
Dbms sixth chapter_part-1_2011 por sumit_study
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011
sumit_study5.3K vistas
Unit no 5 transation processing DMS 22319 por ARVIND SARDAR
Unit no 5 transation processing DMS 22319Unit no 5 transation processing DMS 22319
Unit no 5 transation processing DMS 22319
ARVIND SARDAR644 vistas
Job Opportunity por Sunny Saini
Job OpportunityJob Opportunity
Job Opportunity
Sunny Saini198 vistas
Transaction ps por MR Z
Transaction psTransaction ps
Transaction ps
MR Z2K vistas
acid property.pptx por Ajeet Mish
acid property.pptxacid property.pptx
acid property.pptx
Ajeet Mish7 vistas
Transaction Processing its properties & States por Meghaj Mallick
Transaction Processing its properties & StatesTransaction Processing its properties & States
Transaction Processing its properties & States
Meghaj Mallick31 vistas
Transaction management and concurrency control por Dhani Ahmad
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency control
Dhani Ahmad9.6K vistas
Transaction Properties(ACID Properties) por Yaksh Jethva
Transaction Properties(ACID Properties)Transaction Properties(ACID Properties)
Transaction Properties(ACID Properties)
Yaksh Jethva1.1K vistas

Más de Koteswari Kasireddy

unit-3_Chapter1_RDRA.pdf por
unit-3_Chapter1_RDRA.pdfunit-3_Chapter1_RDRA.pdf
unit-3_Chapter1_RDRA.pdfKoteswari Kasireddy
1 vista52 diapositivas
DBMS_UNIT_1.pdf por
DBMS_UNIT_1.pdfDBMS_UNIT_1.pdf
DBMS_UNIT_1.pdfKoteswari Kasireddy
27 vistas86 diapositivas
business analytics por
business analyticsbusiness analytics
business analyticsKoteswari Kasireddy
51 vistas36 diapositivas
Relational Model and Relational Algebra.pptx por
Relational Model and Relational Algebra.pptxRelational Model and Relational Algebra.pptx
Relational Model and Relational Algebra.pptxKoteswari Kasireddy
5 vistas50 diapositivas
CHAPTER -12 it.pptx por
CHAPTER -12 it.pptxCHAPTER -12 it.pptx
CHAPTER -12 it.pptxKoteswari Kasireddy
4 vistas15 diapositivas
WEB_DATABASE_chapter_4.pptx por
WEB_DATABASE_chapter_4.pptxWEB_DATABASE_chapter_4.pptx
WEB_DATABASE_chapter_4.pptxKoteswari Kasireddy
5 vistas17 diapositivas

Más de Koteswari Kasireddy(20)

Database System Concepts AND architecture [Autosaved].pptx por Koteswari Kasireddy
Database System Concepts AND architecture [Autosaved].pptxDatabase System Concepts AND architecture [Autosaved].pptx
Database System Concepts AND architecture [Autosaved].pptx

Último

Career Building in AI - Technologies, Trends and Opportunities por
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and OpportunitiesWebStackAcademy
41 vistas44 diapositivas
Gross Anatomy of the Liver por
Gross Anatomy of the LiverGross Anatomy of the Liver
Gross Anatomy of the Liverobaje godwin sunday
74 vistas12 diapositivas
Berry country.pdf por
Berry country.pdfBerry country.pdf
Berry country.pdfMariaKenney3
61 vistas12 diapositivas
REFERENCING, CITATION.pptx por
REFERENCING, CITATION.pptxREFERENCING, CITATION.pptx
REFERENCING, CITATION.pptxabhisrivastava11
39 vistas26 diapositivas
11.30.23A Poverty and Inequality in America.pptx por
11.30.23A Poverty and Inequality in America.pptx11.30.23A Poverty and Inequality in America.pptx
11.30.23A Poverty and Inequality in America.pptxmary850239
86 vistas18 diapositivas
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf por
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdfSTRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdf
STRATEGIC MANAGEMENT MODULE 1_UNIT1 _UNIT2.pdfDr Vijay Vishwakarma
90 vistas68 diapositivas

Último(20)

Career Building in AI - Technologies, Trends and Opportunities por WebStackAcademy
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
WebStackAcademy41 vistas
11.30.23A Poverty and Inequality in America.pptx por mary850239
11.30.23A Poverty and Inequality in America.pptx11.30.23A Poverty and Inequality in America.pptx
11.30.23A Poverty and Inequality in America.pptx
mary85023986 vistas
Parts of Speech (1).pptx por mhkpreet001
Parts of Speech (1).pptxParts of Speech (1).pptx
Parts of Speech (1).pptx
mhkpreet00143 vistas
INT-244 Topic 6b Confucianism por S Meyer
INT-244 Topic 6b ConfucianismINT-244 Topic 6b Confucianism
INT-244 Topic 6b Confucianism
S Meyer44 vistas
SURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptx por Niranjan Chavan
SURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptxSURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptx
SURGICAL MANAGEMENT OF CERVICAL CANCER DR. NN CHAVAN 28102023.pptx
Niranjan Chavan43 vistas
JQUERY.pdf por ArthyR3
JQUERY.pdfJQUERY.pdf
JQUERY.pdf
ArthyR3103 vistas
EILO EXCURSION PROGRAMME 2023 por info33492
EILO EXCURSION PROGRAMME 2023EILO EXCURSION PROGRAMME 2023
EILO EXCURSION PROGRAMME 2023
info33492181 vistas
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... por Ms. Pooja Bhandare
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Ms. Pooja Bhandare194 vistas
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv... por Taste
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...
Taste53 vistas
NodeJS and ExpressJS.pdf por ArthyR3
NodeJS and ExpressJS.pdfNodeJS and ExpressJS.pdf
NodeJS and ExpressJS.pdf
ArthyR347 vistas
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice por Taste
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a ChoiceCreative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Taste41 vistas

Unit 4 chapter - 8 Transaction processing Concepts (1).pptx

  • 1. Unit – 4 Chapter - 8 Transaction Processing Concepts
  • 2. INTRODUCTION • Transaction processing system are systems with large databases and hundreds of concurrent users that are executing database transactions. • EX: System for reservations, banking, Credit card processing, stock markets, supermarket checkout, and other similar systems. • They require high availability and fast response time for hundreds of concurrent users. • In this chapter we present the concepts that are needed in transaction processing system.
  • 3. Transaction Processing Concepts Transaction A transaction is the basic logical unit of execution in an information system. A transaction is a sequence of operations that must be executed as a whole, taking a consistent (correct) database state into another consistent (correct) database state. A transaction is a discrete unit of work that must be completely processed (or) not processed at all. Ex: Transferring funds from a checking account to a saving account.
  • 4. Transaction Processing System (TPS) Transaction processing systems are systems with large databases and hundreds of concurrent users that are executing database transactions. Ex: Airline reservation system, Order entry/processing systems, Bank’s account processing systems. Characteristics of TPS are • Large amounts of data are processed • The TPS processes information on a regular basis: daily, weekly, monthly, etc • Large storage (database) capacity is required • High processing speed is needed due to the high volume • TPS basically monitors and collects past data • High reliability is required
  • 5. Transactional processing systems provide three functional areas. 1. System runtime functions • Transaction processing systems provide an execution environment that ensures the integrity, availability, and security of data. • It also ensures fast response time and high transaction throughput . 2. System administration functions • Transaction processing systems provide administrative support that lets users configure, monitor, and manage their transaction system. 3. Application development functions • Transaction processing systems provide functions for use in custom business applications, Including function to access data, to perform inter computer communication etc.
  • 6. Single – user vs. Multi – user System Single-User System • A DBMS is single-user if at most one user can use the system at a time. • The basic components of a transaction processing system can be found in single user systems. • Single-user DBMSs are mostly restricted to personal computer systems. • Presentation Services – displays forms, handles flow of information to/from screen. • Application Services – implements user request, interacts with DBMS.
  • 7. Multi-User System • A DBMS is multi-user if many users can use the system concurrently. • In multi-user system, many users can use the system and hence access the database-concurrently
  • 8. • Dumb terminals connected to mainframe Application and presentation services on mainframe. • ACID properties required Isolation: DBMS sees an interleaved schedule. Atomicity and durability: System supports a major enterprise. • Transaction abstraction, implemented by DBMS, provides ACID properties. Transaction And Systems Concepts Transaction Operations • A transaction is an atomic unit of work that is either completed in its entirety or not not done at all. • For recovery purposes the system needs to keep track of when the transaction starts, starts, terminates and commits (or) aborts. The recovery manager keeps track of the following operations: • Begin_transaction: marks the beginning of the transaction executes.
  • 9. • Read (or) Write : Two possible operations on the data. These specify read or write operations on the database items that are executed as part of a transaction. • End_transaction: Specifies that operations have ended and marks the end of execution. The change can be either committed or aborted. Recovery techniques use the following operators: • undo : similar to rollback except that it applies to a single operation rather than to a whole transaction. • redo : This specifies that certain transaction operations must be redone to ensure that all the operations of a committed transaction have been applied successfully to to the database.
  • 10. Transaction States A transaction is any one execution of a user program in a DBMS, a transaction moves moves through various types of execution states.
  • 11. • Active state – the initial state, The active state is the first state of every transaction. In this state, the transaction is being executed. • Partially committed state - In the partially committed state, a transaction executes its final operation, but the data is still not saved to the database. • Failed state – after the discovery that normal execution can no longer proceed • Aborted state – after the transaction has been rolled backed and the database has been restored to its state prior to the start od transaction. • Committed state - A transaction is said to be in a committed state if it executes all its operations successfully. In this state, all the effects are now permanently saved on the database system.
  • 12. System Log • Log is nothing but a file which contains a sequence of records, each log record refers to a write operation. • All the log records are recorded step by step in the log file. We can say, log files store store the history of all updates activities. • This information may be needed to permit recovery from transaction failures. • Log contains start of transaction, transaction number, record number, old value, new value, end of transaction etc. For example, mini statements in bank ATMs. • The log is kept on disk, so it is not affected by any type of failure except for disk (or) (or) catastrophic failure. • In addition, the log is periodically backed up to archival storage (tape) to guard against such catastrophic failures. • “ T ” in the following discussion refers to a unique transaction-id that is generated generated automatically by the system and is used to identify each transaction.
  • 13. Types of log records • <Ti, Xi, V1, V2> − update log record, where Ti=transaction, Xi=data, V1=old data, V2=new value. • <Ti, start> − Transaction Ti starts execution. • <Ti, commit> − Transaction Ti is committed. • <Ti, abort> − Transaction Ti is aborted  [start_transaction, T ] : Records that transaction T has started execution.  [read_item, T, X] : Records that transaction T has read the value of database item item X.  [commit, T] : Records that transaction T has completed successfully.  [abort, T] : Record that transaction T has been aborted.
  • 14. Commit Point of a Transaction A transaction T is said to reach its commit point only when it completes all its operation that has actually accessed the database and have been executed successfully and the effect of all transaction operation on the database have been recorded in the log. The transaction then writes an entry [commit, T] into the log. • Roll Back of transaction : to erase all data modifications made from the start of the transaction or to a savepoint. • Redoing transactions: Transactions that have written their commit entry in the log must also have recorded all their write operations in the log, otherwise they would not be committed, so their effect on the database can be redone from the log log entries. • Force writing a log: Before a transaction reaches its commit point, any portion of the log that has not been written to the disk yet must now be written to the disk. This process is called force-writing the log file before committing a transaction.
  • 15. Desirable properties of Transaction The transaction has the four properties . In order to maintain consistency in a database, before and after the transaction. These are called ACID properties. ACID properties are applied for maintaining the integrity of database during transaction processing. ACID stands for Atomicity, Consistency, Isolation, and Durability.
  • 16. Atomicity • It states that all operations of the transaction take place at once if not, the transction is aborted. • There is no midway, i.e., the transaction cannot occur partially. Each transaction is is treated as one unit and either run to completion or is not executed at all. Atomicity involves the following two operations: Abort: if a transaction aborts then all the changes made are not visible. Commit: if a transaction commits then all the changes made are visible. Consistency • The integrity constraint are maintained so that the database is consistent before and after the transaction. • The execution of transaction will leave a database in either its prior stable state or or new stable state. • The consistent property of database states that every transaction sees a consistent consistent database instance. • The transaction is used to transform the database from one consistent state to another consistent state
  • 17. Isolation • It shows that the data which is used at the time of execution of a transaction cannot cannot be used by the second transaction until the first one is completed. • In isolation, if the transaction T1 is being executed and using the data item X, then then that data item cant be accessed by any other transaction T2 until the transaction T1 ends. • The concurrency control subsystem of the DBMS enforced the isolation property. property. Durability • guarantees that once a transaction is committed, its effects are permanent and survive any system failures. Together, these properties ensure reliability and maintain data integrity in DBMS operations.
  • 18. (optional) • Atomicity ensures that a transaction is treated as a single indivisible unit, either executing all its operations or none at all. • Consistency ensures that the database remains in a valid state before and after a transaction. • Isolation ensures that concurrent transactions do not interfere with each other, maintaining data integrity. • Durability guarantees that once a transaction is committed, its effects are permanent and survive any system failures. Together, these properties ensure reliability and maintain data integrity in DBMS operations.
  • 19. Transaction Support System in SQL Transaction initiation is done implicitly when SQL statement is executed. Every transaction must have explicit end statement, which is either commit or rollback. Every transaction has certain characteristics: • Access mode: read only (or) read write. • Diagnostic area size: option specifies an integer value n, indicating the number of conditions that can be held simultaneously in the diagnostic area. (The diagnostics area contains two kinds of information:  Statement information, such as the number of conditions that occurred or the affected-rows count.  Condition information, such as the error code and message.) • The isolation level: option that can be read uncommitted, read committed, repeatable read, serializable. (serializable :ensures that multiple transactions can access and modify the same data without interfering with each other’s operations.)
  • 20. If a transaction executes at a lower isolation level than serializable, then one or more of the following violations may occur. Dirty read: Reading a value that was written by a transaction which failed. Non repeatable read: Allowing another transaction to write a new value multiple reads of one transaction. Phantom: A transaction T1 may read a set of rows from a table, then another transaction T2 inserts new rows. If T1 repeated, then it will see a Phantom. (Phantom Read – Phantom Read occurs when two same queries are executed, but the rows retrieved by the two, are different. For example, suppose transaction T1 retrieves a set of rows that satisfy some search criteria. Now, Transaction T2 generates some new rows that match the search criteria for transaction T1)
  • 21. Concurrency Control Techniques • Concurrency control is a database management systems(DBMS) concept that is used to address conflicts with the simultaneous accessing or altering of data that can occur with a multi-user system. • Concurrency control, when applied to a DBMS, is meant to co-ordinate simultaneous transactions while preserving data integrity. The concurrency is about to control the multiuser access of database.
  • 22. Purpose of Concurrency control • enforce isolation among transactions. • preserve database consistency through consistency preserving execution of transactions. • resolve read-write and write-read conflicts. Terms of Concurrency Control Transaction: A transaction is an execution of a user program as a series of reads and writes of database objects Schedules: A schedule is the arrangement of transaction operations. A schedule may contain a set of transactions (Reading, Writing, Aborting or committing)To run transactions concurrently, we arrange or schedule their operations in an interleaved fashion. Serializability: Serialization helps in checking concurrency control between multiple transactions. It also helps in maintaining consistency in the database before and after any transaction. Serializable schedules are resource-efficient and help in improving CPU throughput Or Serializability of a schedule means equivalence to a serial schedule (i.e., sequential with no transaction overlap in time) with the same transactions.
  • 23. Locking System for Concurrency Control
  • 24. Two operations lock item and unlock item are used with binary Locking
  • 25. 2. Shared / exclusive (or) read/Write locks 1. Shared lock: • It is also known as a Read-only lock. In a shared lock, the data item can only read by by the transaction. • It can be shared between the transactions because when the transaction holds a lock, lock, then it can't update the data on the data item. 2. Exclusive lock: • In the exclusive lock, the data item can be both reads as well as written by the transaction. • This lock is exclusive, and in this lock, multiple transactions do not modify the same same data simultaneously. There are three locking operations: 1. read_lock(X) 2. Write_lock(X) 3. Unlock(X)
  • 26. • There are three possible states read locked, write locked(or) unlocked. 1. A read locked item is also called shared-locked because outer transactions are are allowed to read the item. 2. Write locked item is called exclusive-locked because a single transaction exclusively holds the lock on the item. 3. To implement these three operations on a read/write lock is to keep of the number of transactions that hold a shared(read) lock on an item in the lock table. • Shared/ Exclusive locking scheme, the system must enforce the following rules: • A transaction T must issue the operation read_lock(X) (or) before any read- item(X) operation is performed on T • A transaction T must issue the operation write_lock(X) before any write_item(X)
  • 27. • A transaction T will not issue a read_lock(X) operation if it already holds a read lock(or) a write lock in item X. • A transaction T will not issue a write_lock(X) operation if it already holds a read lock (or) write lock on item X.
  • 29. Two phase Locking (2PL) • The two-phase locking protocol divides the execution phase of the transaction into three parts. • In the first part, when the execution of the transaction starts, it seeks permission for the lock it requires. • In the second part, the transaction acquires all the locks. The third phase is started as as soon as the transaction releases its first lock. • In the third phase, the transaction cannot demand any new locks. It only releases the the acquired locks. Two-Phase Locking Techniques : Essential Components 1. Lock Manager: Managing locks on data items. 2. Lock Table: Lock manager uses it to store the identify of transaction locking a data item, the data item, lock mode and pointer to the next data item locked. One simple simple way to implement a lock table is through linked list. • Database requires that all transactions should be well-formed. • It must lock the data item before it reads or write to it.
  • 30. There are two phases of 2PL: • Growing phase: In the growing phase, a new lock on the data item may be acquired by the transaction, but none can be released. • Shrinking phase: In the shrinking phase, existing lock held by the transaction may be released, but no new locks can be acquired. Two Phase policy generates two locking algorithm (a) Basic and (b) Conservative. • Conservative: Prevents deadlocks by locking all desired data items before transaction begins execution. • Basic: Transaction locks data items incrementally. This may cause deadlock which is dealt with.
  • 31. Problems caused by use of Locks The use of locks, can cause two problems, they are • Deadlock • Starvation Deadlock • A system is in a deadlock state if there exists a set of transactions such that every transaction in the set in waiting for another transaction in the set. • A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting resulting in both programs ceasing function. Ex: there exists a set of waiting transaction {T0, T1,……Tn} such that T0 is waiting for for data item that is held by T1, T1 is waiting for a data item that is held by T2, Tn-1 is 1 is waiting for a data item that is held by Tn, and Tn is waiting for a data item that is is held by T0. None of the transactions can make progress in such a situation.
  • 32. Dealing with Deadlock and Starvation Deadkock prevention • A transaction locks all data items it refers to before it begins execution. • This way of locking prevents deadlock since a transaction never waits for a data item. • The conservative two-locking uses this approach.
  • 33. Deadlock detection and resolution • In this approach, deadlocks are allowed to happen. The scheduler maintains a wait-for-graph for detecting cycle. If a cycle exists, then one transaction involved involved in then cycle is selected (victim) and roller-back. • A wait-for-graph is created using the lock table. As soon as a transaction is blocked, it is added to the graph. When a chain like: Ti waits for Tj waits for Tk waits for Ti or Tj occurs, then this creates a cycle. Deadlock avoidance • There are many variations of two-phase locking algorithm. • Some avoid deadlock by not letting the cycle to complete. • That is as soon as the algorithm discovers that blocking a transaction is likely to create a cycle, it rolls back the transaction.
  • 34. Starvation • Starvation occurs when a particular transaction consistently waits or restarted and and never gets a chance to proceed further. • In a deadlock resolution it is possible that the same transaction may consistently be be selected as victim and rolled-back. • The limitation is inherent in all priority based scheduling mechanisms. • In wound-wait scheme a younger transaction may always be wounded (aborted) by by a long running older transaction which may create starvation.
  • 35. DeadLock Prevention A deadlock can be prevented by following two commonly used schemes. 1. Wait – die 2. Wound-wait Wait-die Scheme
  • 36. (Non-Preemptive Scheduling is one in which once the resources (CPU Cycle) have been allocated to a process, the process holds it until it completes its burst time or switches to the 'wait' state. In non-preemptive scheduling, a process cannot be interrupted until it terminates itself or its time is over.) (Preemptive Scheduling is a CPU scheduling technique that works by dividing time slots of CPU to a given process. The time slot given might be able to complete the whole process or might not be able to it.)
  • 37. 2. Wound – Wait scheme
  • 39. Recovery Techniques Database recovery techniques are used in database management systems (DBMS) (DBMS) to restore a database to a consistent state after a failure or error has occurred. The main goal of recovery techniques is to ensure data integrity and consistency and prevent data loss.
  • 43. Concurrency Control Based on Time Stamp Ordering • Timestamp TS(T) is a unique identifier created by DBMS to identify the transaction • The timestamp values are assigned in the order in which the transaction are submitted to the system • The timestamp can be generated using a counter that is incremented each time its its value is assigned to a transaction • Timestamp ordering algorithm (TO) it orders the transaction according to their timestamps • It generates serializability of schedules • The algorithm must ensure that for each item accessed by conflicting operations in in the schedule, does not violate the serializability order.
  • 44. Database Backup and Recovery from Catastrophic Failures