ch8 Transactions and Concurrency Control_第1頁
ch8 Transactions and Concurrency Control_第2頁
ch8 Transactions and Concurrency Control_第3頁
ch8 Transactions and Concurrency Control_第4頁
ch8 Transactions and Concurrency Control_第5頁
已閱讀5頁,還剩98頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、8.1Chapter 8 Transactions and Concurrency Controln8.1 Transaction Conceptn8.2 Transactions & Schedules(調度)(調度)n8.3 Concurrent Executionsn8.4 Concurrency Controln8.5 Transactions in SQLn8.6 Isolation(隔離)(隔離) Levelsn8.7 Pitfalls of Lock-Based Protocols8.28.1 TransactionsnDatabase systems are normally

2、being accessed by many users or processes at the same time. (e.g. Airline reservations)HBoth queries and modifications.nUnlike Operating Systems, which support interaction of processes, a DMBS needs to keep processes from troublesome interactions. (e.g. Banking)8.3nA transaction is a means by which

3、an application programmer can package together a sequence of database operations so that the database system can provide a number of guarantees.nTransaction is a set of changes that must all be made together.事務是具有完整邏輯意義的數據庫操作序列的集合。對于事務是具有完整邏輯意義的數據庫操作序列的集合。對于DBMS而言,事務是一個讀寫操作的序列,這些操作是一個不而言,事務是一個讀寫操作的序

4、列,這些操作是一個不可分割的邏輯工作單元,要么都做,要么都不做。可分割的邏輯工作單元,要么都做,要么都不做。事務是構成數據庫處理邏輯單元的可執行程序,由用戶定義的事務是構成數據庫處理邏輯單元的可執行程序,由用戶定義的一組操作序列(包括插入、刪除、修改或檢索等操作)組成,一組操作序列(包括插入、刪除、修改或檢索等操作)組成,序列中的操作要么全做,要么全不做,是一個不可分割的工作序列中的操作要么全做,要么全不做,是一個不可分割的工作單位。單位。8.4nWhy we need transaction - transaction(交易交易) - booking - fund transfer The

5、need of restoration 恢復的需要恢復的需要 The need for concurrent operation并發操作的需要并發操作的需要H買賣交易買賣交易一手交錢一手交貨一手交錢一手交貨H訂票訂票查詢、訂位、查詢、訂位、(交錢交錢)、出票(往返票?)、出票(往返票?)H轉帳轉帳轉出、轉入轉出、轉入8.5James Gray1998年獲得圖靈獎年獲得圖靈獎n在數據庫技術、特別是事務處理方面做出了杰在數據庫技術、特別是事務處理方面做出了杰出貢獻。出貢獻。n解決了諸如完整性、安全性、并發控制等一系解決了諸如完整性、安全性、并發控制等一系列技術難題。列技術難題。8.6James N

6、. Gray1966年從年從Berkeley獲獲得其工程數學的學士學位,并于得其工程數學的學士學位,并于1969年獲得其計算機科學的博士學位。年獲得其計算機科學的博士學位。Gray博士畢業后,加入了工業界,先博士畢業后,加入了工業界,先后任職于后任職于IBM( ),Tandem( , 已經是已經是HP( )的一部分和的一部分和DEC( ,目前已是,目前已是HP的的一部分一部分)。目前,目前,Gray任職與微軟研究院任職與微軟研究院(http:/ ),主要從事大型數據庫和事務處理,主要從事大型數據庫和事務處理的研究。的研究。8.7nExample: 飛機訂票系統有兩個表飛機訂票系統有兩個表Sal

7、e,Flight,分別記錄各分別記錄各售票點的售票數及全部航班的剩余票數售票點的售票數及全部航班的剩余票數 Sale(agentNo,flightNo,date,saleNumber) Flight(flightNo,date,remainNumber) 現有現有A0010售票點欲出售售票點欲出售F005航班航班2014年年12月月8日機票日機票2張張8.8n(1)查詢)查詢F005航班航班2014年年12月月8日剩余票數日剩余票數 (2)IF(A2) 拒絕操作,并通知票不足拒絕操作,并通知票不足 ELSE 更新更新A0010的售票數及航班的剩余票數的售票數及航班的剩余票數8.9nSELECT

8、 remainNumbernFROM FlightnWHERE flightNo=F005AND date=2014-12-08nUPDATE SalenSet saledNumber=saledNumber+2nWHERE agentNo=A0010 AND flightNo=F005 AND date=2014-12-08nUPDATE FlightnSET remainNumber=remainNumber-2nWHERE flight=F005 AND date=2014-12-088.10n銀行轉賬業務,從賬戶銀行轉賬業務,從賬戶A轉出轉出1000元到賬戶元到賬戶B,通過兩個業務完成

9、,哪兩個?,通過兩個業務完成,哪兩個?8.11nCommit:事務提交事務提交 將成功完成事務的執行結果(即更新)永久化將成功完成事務的執行結果(即更新)永久化,并釋放事務占有的全部資源,并釋放事務占有的全部資源nRollback :事務回滾:事務回滾 終止當前的事務,撤銷其對數據庫所做的更新終止當前的事務,撤銷其對數據庫所做的更新,并釋放事務占有的全部資源,并釋放事務占有的全部資源8.12Transaction ConceptnTransaction to transfer $50 from account A to account B:1. read(A)2. A := A 503. wr

10、ite(A)4. read(B)5. B := B + 506. write(B)8.13nIf the machine crashes in between the step 4 and 5, the money has already been subtracted from the account A, but it will not be added to account B. The $50 is lost. nIf the system crashes before the end of the transactions (Commit), none of the changes

11、are written to the database. On restart, the changes may all be rolled back, or the transaction restarted. 8.14TransactionsnThe solution to the problems of serialization(可串可串行化)行化) and atomicity is to group database operations into transactions.nA transaction is a collection of one or more operation

12、s on the database that must be executed atomically, that is, either all operations are performed or none are.All-or-None原則原則8.15ACID TransactionsnA DBMS is expected to support “ACID transactions”, which are:HAtomic: Either the whole process is done or none is. This property guarantees that a set of

13、record that are part of a transaction is indivisible . Thus either all operations of the transaction are properly reflected in the database or none are.事務中包含的所有操作要么全做,要么全不做事務中包含的所有操作要么全做,要么全不做, 原子性由恢復機制實現原子性由恢復機制實現8.16HConsistent: Database constraints are preserved. Database consistency is the prope

14、rty that every transaction sees a consistent database instance. 事務的隔離執行必須保證數據庫的一致性事務的隔離執行必須保證數據庫的一致性事務開始前,數據庫處于一致性的狀態;事務結束后,數據庫必須仍事務開始前,數據庫處于一致性的狀態;事務結束后,數據庫必須仍處于一致性狀態處于一致性狀態數據庫的一致性狀態由數據庫的一致性狀態由用戶來負責,由并發控制機制實現來負責,由并發控制機制實現如銀行轉帳,轉帳前后兩個帳戶金額之和應保持不變如銀行轉帳,轉帳前后兩個帳戶金額之和應保持不變8.17HIsolated (隔離性隔離性) : It appe

15、ars to the user as if only one process executes at a time. Although multiple transactions may execute concurrently, each transaction must be unaware of other concurrently executing transactions. Intermediate transaction results must be hidden from other concurrently executed transactions. 系統必須保證事務不受

16、其它并發執行事務的影響系統必須保證事務不受其它并發執行事務的影響對任何一對事務對任何一對事務T1,T2,在,在T1看來,看來,T2要么在要么在T1開開始之前已經結束,要么在始之前已經結束,要么在T1完成之后再開始執行完成之后再開始執行隔離性通過并發控制機制實現隔離性通過并發控制機制實現8.18HDurable(長期的)(長期的): Effects of a process do not get lost if the system crashes. After a transaction completes successfully, the changes it has made to th

17、e database persist, even if there are system failures. 一個事務一旦提交之后,它對數據庫的影響必須是永久的一個事務一旦提交之后,它對數據庫的影響必須是永久的系統發生故障不能改變事務的持久性系統發生故障不能改變事務的持久性持續性通過恢復機制實現持續性通過恢復機制實現8.19Example of Fund TransfernTransaction to transfer $50 from account A to account B:1. read(A)2. A := A 503. write(A)4. read(B)5. B := B + 5

18、06. write(B)n(1) Consistency requirement the sum of A and B is unchanged by the execution of the transaction.8.20Example of Fund Transfer(Cont.)n(2) Atomicity requirement if the transaction fails after step 3 and before step 6, the system should ensure that its updates are not reflected in the datab

19、ase, else an inconsistency will result.8.21Example of Fund Transfer(Cont.)n(3) Durability requirement once the user has been notified that the transaction has completed (i.e., the transfer of the $50 has taken place), the updates to the database by the transaction must persist despite failures.8.22E

20、xample of Fund Transfer (Cont.)n(4) Isolation requirement if between steps 3 and 6, another transaction is allowed to access the partially updated database, it will see an inconsistent database (the sum A + B will be less than it should be).8.23Example of Fund Transfer (Cont.)nCan be ensured trivial

21、ly(平凡)(平凡) by running transactions serially, that is one after the other. nHowever, executing multiple transactions concurrently has significant benefits, as we will see.8.242) Transaction State (Cont.)activefailedcommitrollbackPartially committed8.251. BEGIN TRANSACTION2. READ/WRITE TRANSACTION3. C

22、OMMIT TRANSACTION 事務完成所有數據操作,同時保存操作結果,事務完成所有數據操作,同時保存操作結果, 它標志著事務成功完成。它標志著事務成功完成。4. ROLLBACK TRANSACTION 事務未完成所有數據操作,重新返回到事務開始狀態,標志著事務的撤銷事務未完成所有數據操作,重新返回到事務開始狀態,標志著事務的撤銷.8.26nSQLServer提供了提供了3種類型的事務模式種類型的事務模式 顯式事務顯式事務 使用使用SQL事務定義的語句定義事務事務定義的語句定義事務 隱式事務隱式事務 事務提交或回滾后,事務提交或回滾后,SQL Server自動開始新自動開始新事務事務 自

23、定義事務自定義事務 一個語句成功執行后,被自動提交,而當執行一個語句成功執行后,被自動提交,而當執行過程中出錯后,自動回滾過程中出錯后,自動回滾8.27Transactions in SQLnSQL supports transactions, often behind the scenes.HEach statement issued at the generic query interface is a transaction by itself.HIn programming interfaces like Embedded SQL, a transaction begins the f

24、irst time an SQL statement is executed and ends with the program or an explicit end.當使用基本的當使用基本的SQL界面,即使用方便人們提交查詢和別的界面,即使用方便人們提交查詢和別的SQL語句的工具時,每條語句自身就是一個事務。語句的工具時,每條語句自身就是一個事務。8.28Transactions in SQLnStart Transaction HBEGIN TRANSACTIONnEnd TransactionHCOMMIT TRANSACTIONHROLLBACK TRANSACTION數據庫應用程序中

25、,事務以數據庫應用程序中,事務以BEGIN_TRANSACTION語句開始,語句開始,以以COMMIT或或ROLLBACK語句結束。語句結束。8.29COMMITnThe SQL statement COMMIT causes a transaction to complete.HIts database modifications are now permanent in the database.8.30ROLLBACKnThe SQL statement ROLLBACK also causes the transaction to end, but by aborting.HNo ef

26、fects on the database.nFailures like division by 0 can also cause rollback, even if the programmer does not request it.8.311st Sample TransactionnBEGIN TRANSACTIONnCREATE TABLE test1 (id int, lname varchar(20) default unknown);nINSERT INTO test1 VALUES(1,default);nINSERT INTO test1 VALUES (2,default

27、);nINSERT INTO test1 VALUES (3,default);nSELECT * FROM test1;nCOMMIT TRANSACTIONnSELECT * FROM test1;8.322nd Sample TransactionnBEGIN TRANSACTIONnCREATE TABLE test2 (id int, lname varchar(20) default unknown);nINSERT INTO test2 VALUES(1,default);nINSERT INTO test2 VALUES(2,default);nINSERT INTO test

28、2 VALUES(3,default);nSELECT * FROM test2;nROLLBACK TRANSACTIONnSELECT * FROM test2;8.333rd Sample TransactionnBEGIN TRANSACTIONnINSERT INTO test1 VALUES (4,default);nINSERT INTO test1 VALUES (5,default);nINSERT INTO test1 VALUES (6,default);nINSERT INTO test1 VALUES(default);nSELECT * FROM test1;nRO

29、LLBACK TRANSACTIONnSELECT * FROM test1; 8.34Problems hiding in concurrent operationsnLose update (丟失更新)(丟失更新)nDirty Read (讀臟數據)(讀臟數據)nUnrepeatable read(不可重復讀)(不可重復讀)8.35Example: Lose update nYou and your spouse each take $100 from different ATMs at about the same time.HThe DBMS better make sure one

30、account deduction doesnt get lost.nCompare: An OS allows two people to edit a document at the same time. If both write, ones changes get lost.8.36nExample 飛機訂票系統,假設某航班剩余飛機訂票系統,假設某航班剩余16張機票,張機票,A售票點(售票點(事務事務T1)賣了一張票,)賣了一張票,B售票點(事務售票點(事務T2)賣掉一張)賣掉一張票,如果正常操作,即事務票,如果正常操作,即事務T1執行完再執行執行完再執行T2,則剩,則剩余余14張機票

31、。將兩個事務拆分張機票。將兩個事務拆分 T1(1):):T1讀取機票余額讀取機票余額 T1(2): T1修改機票余額修改機票余額R=R-1 T2(1):):T2讀取機票余額讀取機票余額 T2(2):):T2 修改機票余額修改機票余額R=R-1 如果執行順序如下:如果執行順序如下: T1(1) T2(1) T1(2) T2(2) 則余票為?則余票為? 原因?原因?T2執行時丟失了執行時丟失了T1對數據庫的更新對數據庫的更新8.37Example: Lose update并發操作引起的丟失修改并發操作引起的丟失修改nTransaction T1 update the data , but it c

32、overed by the data which is modified by transaction T2 T1Read: A=16A=A-1Write: A15T2Read:A=16A=A-1Write:A15事務事務T1對數據的對數據的修改被事務修改被事務T2的的修改覆蓋修改覆蓋8.38Example: Dirty readnDirty data is common term for data written by a transaction that has not yet committed.nA dirty read is a read of dirty data written

33、by another transaction.臟數據:還沒有提交的事務所寫的數據臟數據:還沒有提交的事務所寫的數據臟讀:對臟數據的讀取臟讀:對臟數據的讀取8.39n事務事務T1 修改了某數修改了某數據并寫回磁盤,事據并寫回磁盤,事務務T2 讀取了同一數讀取了同一數據后,據后,T1由于某種由于某種原因被撤銷,被修原因被撤銷,被修改的值復原,此時改的值復原,此時T2讀到的數據與數讀到的數據與數據庫中的數據不一據庫中的數據不一致致T1Read: C=1C=C*2Write: C=2ROLLBACKC恢復為1T2Read:C=2Example: Dirty read8.40Example: Unrep

34、eatable ReadnThe same query issued more than once is not quite guaranteed to get the same answer.nIt is possible that a second or subsequent execution of the same query will retrieve phantom(幻影)(幻影) tuples.8.41Unrepeatable Readn事務事務T1讀取某一數據后讀取某一數據后,事務,事務T2對其做了修改對其做了修改,當,當T1按同樣條件再讀按同樣條件再讀時得到不同的值時得到不同

35、的值n事務事務T1讀取某些數據后讀取某些數據后,事務,事務T2刪除刪除(或插入或插入)了一些記錄,當了一些記錄,當T1按同按同樣條件再讀時發現少樣條件再讀時發現少(或或多多)了一些記錄了一些記錄T1read:A=1,B=2Solve A+B=3Read:A=1,B=4Solve:A+B=5T2Read:B=2B=B*2Write:B=48.42n事務事務Ti兩次從數據庫中讀取的結果不同,可分為三種情兩次從數據庫中讀取的結果不同,可分為三種情況:況:1) Ti 讀取一數據后,讀取一數據后, Tj對該數據進行了更改。當對該數據進行了更改。當Ti 再次再次讀該數據時,則會讀到與前一次不同的值讀該數據

36、時,則會讀到與前一次不同的值2) Ti 按某條件讀取數據庫中某些記錄后,按某條件讀取數據庫中某些記錄后, Tj刪除了其中刪除了其中部分記錄。當部分記錄。當Ti 再次按相同條件讀取時,發現記錄變再次按相同條件讀取時,發現記錄變少了少了3) Ti 按某條件讀取數據庫中某些記錄后,按某條件讀取數據庫中某些記錄后, Tj插入了新的插入了新的記錄。當記錄。當Ti 再次按相同條件讀取時,發現記錄變多了再次按相同條件讀取時,發現記錄變多了 2)3)兩種不可重復讀稱為幻影現象)兩種不可重復讀稱為幻影現象phantom tuples.8.438.2 Transactions & SchedulesnA tran

37、saction is seen by the DBMS as a series or list of actions. The actions that can be executed by a transaction include reads and writes of database objects.nTwo assumptions:HTransactions interact with each other only via database read and write operations. They are not allowed to exchange messages.HA

38、 database is a fixed collection of independent objects.8.448.2 Transactions & SchedulesnA schedule (調度)(調度)is a list of actions (reading, writing, rollbacking, or committing) from a set of transactions, and the order in which two actions of a transaction T appear in a schedule must be the same as th

39、e order in which they appear in T.nA schedule represents an actual or potential execution sequence.事務并發執行順序是隨機的,將由多個事務操作組成的隨機事務并發執行順序是隨機的,將由多個事務操作組成的隨機執行序列稱為一個調度。執行序列稱為一個調度。8.458.2 Transactions & SchedulesnThe effect of a transaction on another transaction can be understood solely in terms of the co

40、mmon database objects that they read and write.8.468.2 Transactions & SchedulesnIf the actions of different transactions are not interleaved(交錯的)(交錯的)-that is, transactions are executed from start to finish, one by one-we call the schedule a serial schedule(串行調度)(串行調度).nIf the actions of different t

41、ransactions are interleaved, we call the schedule a concurrent schedule.8.478.2 Transactions & SchedulesnExample :HTwo transactions are T0 and T1 . T0 transfers $50 from account A to account B. T1 transfers the 10% of money of account A to account B. HBefore the transformation, there is $1000 in acc

42、ount A and $2000 in account B. The sum of the two accounts must be $3000 and can not be changed.8.488.2 Transactions & SchedulesnSerial scheduleT0T1read(A1)A1 := A1 50write(A1)read(B1)B1 := B1 + 50write(B1)read(A2)temp:=A2*0.1A2 := A2 tempwrite(A2)read(B2)B2 := B2 + tempwrite(B2) After the transform

43、ation, there is $855 in account A and $2145 in account B . The sum of money in them is still $3000.8.498.2 Transactions & SchedulesnSerial scheduleT0T1read(A2)A2 := A2 50write(A2)read(B2)B2 := B2 + 50write(B2)read(A1)temp:=A1*0.1A1 := A1 tempwrite(A1)read(B1)B1 := B1 + tempwrite(B1) After the transf

44、ormation, there is $850 in account A and $2150 in account B . The sum of money in them is still $3000.8.508.2 Transactions & SchedulesnConcurrent scheduleT0T1read(A1)A1 := A1 50write(A1)read(B1)B1 := B1 + 50write(B1)read(A2)temp:=A2*0.1A2 := A2 tempwrite(A2)read(B2)B2 := B2 + tempwrite(B) After the

45、transformation, there is $855 in account A and $2145 in account B . The sum of money in them is still $3000.8.518.2 Transactions & SchedulesnConcurrent scheduleT0T1read(A1)A1 := A1 50write(A1)read(B1)B1 := B1 + 50write(B1)read(A2)temp:=A2*0.1A2 := A2 tempwrite(A2)read(B2)B2 := B2 + tempwrite(B)After

46、 the transformation, there is $950 in account A and $2100 in account B . The sum of money in them is $3050. The sum of money is changed.S4 is a wrong schedule because the sum of money is not consistent.8.52Serial Scheduling(1)nLet T1 transfer $50 from A to B, and T2 transfer 10% of the balance from

47、A to B. nInitial status : A ($1,000), B($2,000) total : $3,000 1) T1 T2 2) T2 T1 A: 1,000 950 B: 2,000 2,050 A: 1,000 900 B: 2,000 2,100 DatabaseDatabase8.53Serial Scheduling(2) 3) T1 T2 T1 T2 4) T1 T2 T1 T2 A: 1,000 950 B: 2,000 2,050 A: 1,000 900 B: 2,000 2,050 DatabaseDatabase1,0001,0009009502,00

48、02,0002,0502,1001,0009509508652,0002,0502,0502,050950 - 952,000+502,050+951,000-501,000-502,000-1008.548.2 Transactions & SchedulesnIf there are n transactions , there will be n! serial schedules and more than n! concurrent schedules. nA good concurrent schedule should not only have the same effect

49、as the serial schedules ,but also execute efficiently.8.558.2 Transactions & SchedulesnIf a concurrent schedule is equivalent to the serial schedule, then we call the concurrent schedule is a serializable schedule.nTwo schedules are equivalent when two operations in different transactions conflict ,

50、 and the order in which the operations occur is important. nThat is the order of the conflicting operations can be changed without breaking the consistency of the data. 8.568.2 Transactions & SchedulesnConflicting operations: If the operations reference the same data item and at least one of them is

51、 a write, the two operations are conflicting operations.n1)read(Q) ,write(Q)n2) write(Q),read(Q)n3) write(Q), write(Q)Conflicting operations 沖突操作沖突操作:在一調度中在一調度中,如果如果Qi和和Qj是不同事務在相同數據是不同事務在相同數據對象上的操作,并且其中至少有一個是寫操作,則稱對象上的操作,并且其中至少有一個是寫操作,則稱Qi和和Qj是沖突操作是沖突操作8.57read(Q)write(P)8.2 Transactions & Schedules

52、nIf two operations are not conflicting operations, their order to operate can be switched(轉換)(轉換).T1T2read(Q)write(P)T1T1T2read(Q)write(P)read(Q)write(Q) S5nIn S5, write(P) in T1 and write(Q) are not conflicting operations, then we switch their order and get S6. Further, we get S7 by switching the o

53、rder of write(P) and read(Q).read(Q)write(Q)read(Q)write(Q)S6S7T28.588.2 Transactions & SchedulesnConflict Equivalent: (沖突等價)(沖突等價) If schedule S can became S by switching the order of its operations without conflicts , then S and S are conflict equivalent.nConflict Serializable Schedule:沖突可串行化沖突可串行

54、化 If a concurrent schedule S is conflict equivalent to the serial schedule S on the same transactions , S is a conflict serializable schedule如果一調度如果一調度S與一串行調度是沖突等價的,則稱與一串行調度是沖突等價的,則稱S是是沖突可串行化沖突可串行化8.59T4T5ABR(A)A=A-2W(A)R(A)A=A-3W(A)R(B)B=B-2W(B)R(B)B=B-3W(B)1088515131310T4T5R(A)A=A-2W(A)R(B)B=B-2W(

55、B)R(A)A=A-3W(A)R(B)B=B-3W(B)A=10,B=15Concurrent ScheduleConflict Serializable Schedule8.608.3 Concurrent ExecutionsnMultiple transactions are allowed to run concurrently in the system. nAdvantages are:Hincreased processor and disk utilization, leading to better transaction throughput: one transactio

56、n can be using the CPU while another is reading from or writing to the diskHreduced average response time for transactions: short transactions need not wait behind long ones.8.618.3 Concurrent ExecutionsnConcurrency control schemes mechanisms to achieve isolation, i.e., to control the interaction am

57、ong the concurrent transactions in order to prevent them from destroying the consistency of the database.8.628.3 Lock-Based ProtocolsnMultiple transactions executed at same timeHother applications have access to inconsistent (intermediate) stateHsolution: Lock-Based Protocols8.638.4 Lock-Based Proto

58、colsnA lock is a mechanism to control concurrent access to a data item.nData items can be locked in two modes : 1. exclusive (X) mode. Data item can be both read as well as written. X-lock is requested using lock-X instruction. 排他鎖排他鎖 2. shared (S) mode. Data item can only be read. S-lock is request

59、ed using lock-S instruction. 共享鎖共享鎖nLock requests are made to concurrency-control manager. Transaction can proceed only after request is granted.8.64n排它鎖(X鎖) 排他鎖也稱為獨占鎖或寫鎖。一旦事務排他鎖也稱為獨占鎖或寫鎖。一旦事務T對數據對對數據對象象A加上排它鎖加上排它鎖(X鎖鎖),則只允許,則只允許T讀取和修改讀取和修改A,其他,其他任何事務既不能讀取和修改任何事務既不能讀取和修改A,也不能再對,也不能再對A加任何類加任何類型的鎖,直到型

60、的鎖,直到T釋放釋放A上的鎖為止。上的鎖為止。n共享鎖(S鎖)共享鎖又稱讀鎖。如果事務共享鎖又稱讀鎖。如果事務T對數據對象對數據對象A加上共加上共享鎖享鎖(S鎖鎖),事務,事務T對數據對象對數據對象A只能讀不能修改,其他只能讀不能修改,其他事務對事務對A只能再加只能再加S鎖,不能加鎖,不能加X鎖,直到事務鎖,直到事務T釋放釋放A上的上的S鎖為止。鎖為止。8.658.3 Lock-Based ProtocolsnTransactions obtain locks on objects xHS-locks (shared) for read: slock(x)HX-locks (exclusive

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論