数据库-事务管理的详细讲解

上传人:陈** 文档编号:181689070 上传时间:2023-01-15 格式:PPT 页数:32 大小:1.08MB
收藏 版权申诉 举报 下载
数据库-事务管理的详细讲解_第1页
第1页 / 共32页
数据库-事务管理的详细讲解_第2页
第2页 / 共32页
数据库-事务管理的详细讲解_第3页
第3页 / 共32页
资源描述:

《数据库-事务管理的详细讲解》由会员分享,可在线阅读,更多相关《数据库-事务管理的详细讲解(32页珍藏版)》请在装配图网上搜索。

1、1Transaction Management2ObjectivesuFunction and importance of transactions.uProperties of transactions.uConcurrency Control Meaning of serializability.How locking can ensure serializability.Deadlock and how it can be resolved.Granularity of locking.3ObjectivesuRecovery Control Some causes of databas

2、e failure.Purpose of transaction log file.How to recover following database failure.4Transaction SupportTransactionAction,or series of actions,carried out by user or application,which accesses or changes contents of database.uLogical unit of work on the database.uApplication program is series of tra

3、nsactions with non-database processing in between.uTransforms database from one consistent state to another,although consistency may be violated during transaction.5Example Transaction6Transaction SupportuCan have one of two outcomes:Success-transaction commits and database reaches a new consistent

4、state.Failure-transaction aborts,and database must be restored to consistent state before it started.Such a transaction is rolled back or undone.uCommitted transaction cannot be aborted.uAborted transaction that is rolled back can be restarted later.7State Transition Diagram for Transaction 8Propert

5、ies of Transactions uFour basic(ACID)properties of a transaction are:Atomicity All or nothing property.Consistency Must transform database from one consistent state to another.Isolation Partial effects of incomplete transactions should not be visible to other transactions.DurabilityEffects of a comm

6、itted transaction are permanent and must not be lost because of later failure.9DBMS Transaction Subsystem10Concurrency Control Process of managing simultaneous operations on the database without having them interfere with one another.uPrevents interference when two or more users are accessing databa

7、se simultaneously and at least one is updating data.uAlthough two transactions may be correct in themselves,interleaving of operations may produce an incorrect result.11Need for Concurrency ControluThree examples of potential problems caused by concurrency:Lost update problem.Uncommitted dependency

8、problem.Inconsistent analysis problem.12Lost Update ProblemuSuccessfully completed update is overridden by another user.uT1 withdrawing 10 from an account with balx,initially 100.uT2 depositing 100 into same account.uSerially,final balance would be 190.13Lost Update ProblemuLoss of T2s update avoide

9、d by preventing T1 from reading balx until after update.14Uncommitted Dependency ProblemuOccurs when one transaction can see intermediate results of another transaction before it has committed.uT4 updates balx to 200 but it aborts,so balx should be back at original value of 100.uT3 has read new valu

10、e of balx(200)and uses value as basis of 10 reduction,giving a new balance of 190,instead of 90.15Uncommitted Dependency ProblemuProblem avoided by preventing T3 from reading balx until after T4 commits or aborts.16Inconsistent Analysis ProblemuOccurs when transaction reads several values but second

11、 transaction updates some of them during execution of first.uSometimes referred to as dirty read or unrepeatable read.uT6 is totaling balances of account x(100),account y(50),and account z(25).uMeantime,T5 has transferred 10 from balx to balz,so T6 now has wrong result(10 too high).17Inconsistent An

12、alysis ProblemuProblem avoided by preventing T6 from reading balx and balz until after T5 completed updates.18SerializabilityScheduleSequence of reads/writes by set of concurrent transactions.Serial ScheduleSchedule where operations of each transaction are executed consecutively without any interlea

13、ved operations from other transactions.uNo guarantee that results of all serial executions of a given set of transactions will be identical.19Nonserial ScheduleuSchedule where operations from set of concurrent transactions are interleaved.uObjective of serializability is to find nonserial schedules

14、that allow transactions to execute concurrently without interfering with one another.uIn other words,want to find nonserial schedules that are equivalent to some serial schedule.Such a schedule is called serializable.20Concurrency Control TechniquesuTwo basic concurrency control techniques:Locking,T

15、imestamping.21LockingTransaction uses locks to deny access to other transactions and so prevent incorrect updates.uGenerally,a transaction must claim a shared(read)or exclusive(write)lock on a data item before read or write.uLock prevents another transaction from modifying item or even reading it,in

16、 the case of a write lock.22Locking-Basic RulesuIf transaction has shared lock on item,can read but not update item.uIf transaction has exclusive lock on item,can both read and update item.uReads cannot conflict,so more than one transaction can hold shared locks simultaneously on same item.uExclusiv

17、e lock gives transaction exclusive access to that item.23Two-Phase Locking(2PL)Transaction follows 2PL protocol if all locking operations precede first unlock operation in the transaction.uTwo phases for transaction:Growing phase-acquires all locks but cannot release any locks.Shrinking phase-releas

18、es locks but cannot acquire any new locks.24Preventing Lost Update Problem using 2PL25Preventing Uncommitted Dependency Problem using 2PL26Preventing Inconsistent Analysis Problem using 2PL27DeadlockAn impasse that may result when two(or more)transactions are each waiting for locks held by the other

19、 to be released.28Database Recovery Process of restoring database to a correct state in the event of a failure.29Recovery FacilitiesuDBMS should provide following facilities to assist with recovery:Backup mechanism,which makes periodic backup copies of database.Logging facilities,which keep track of

20、 current state of transactions and database changes.Checkpoint facility,which enables updates to database in progress to be made permanent.Recovery manager,which allows DBMS to restore database to consistent state following a failure.30Log Fileu Transaction records contain:Transaction identifier.Typ

21、e of log record,(transaction start,insert,update,delete,abort,commit).Identifier of data item affected by database action(insert,delete,and update operations).Before-image of data item.After-image of data item.Log management information.31Sample Log File32Log FileuLog file may be duplexed or triplexed.uLog file sometimes split into two separate random-access files.uPotential bottleneck;critical in determining overall performance.

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!