tailieunhanh - Bài giảng Thiết kế và quản trị cơ sở dữ liệu - Chương 5: Concurrency

Nội dung chính được trình bày trong chương này gồm có: Transaction, automicity, consistency, isolation, durability, transaction states, transaction management interfaces, concurrency control, serializability,. | Concurrency Vu Tuyet Trinh trinhvt@ Department of Information Systems, Faculty of Information Technology Hanoi University of Technology Example 500USD Account A Account B read(A) If A > 500 then B:=B+500 A:=A-500 Crash What happen ??? 2 1 Transaction A sequence of read and write operations on data items that logically functions as one unit of work Assuring data integrity and correction ACID Properties Concurrency Control Atomicity Consistency Isolation Durability Recovery 3 Automicity guarantee that either all of the tasks of a transaction are performed or none of them are Example T: Read(A,t1); If t1 > 500 { Read(B,t2); t2:=t2+500; Write(B,t2); t1:=t1-500; Write(A,t1); } crash 4 2 Consistency ensures that the DB remains in a consistent state before the start of the transaction and after the transaction is over Example A+B = C T: Read(A,t1); If t1 > 500 { Read(B,t2); t2:=t2+500; Write(B,t2); t1:=t1-500; Write(A,t1); } A+B = C 5 Isolation ability of the application to make operations in a transaction appear isolated from all other operations. Example A= 5000, B= 3000 T: Read(A,t1); If t1 > 500 { Read(B,t2); t2:=t2+500; Write(B,t2); t1:=t1-500; Write(A,t1); } T’: A+B (= 5000+3500) (A+B = 4500+3500) 6 3 Durability guarantee that once the user has been notified of success, the transaction will persist, and not be undone Ví dụ: A= 5000, B= 3000 T: Read(A,t1); If t1 > 500 { Read(B,t2); t2:=t2+500; Write(B,t2); t1:=t1-500; Write(A,t1); } crash 7 A= 4500, B=3500 Transaction States 8 4 Transaction Management Interfaces Begin Trans Commit () Abort() Savepoint Save() Rollback (savepoint) (savepoint = 0 ==> Abort) 9 Concurrency Control Objective: ensures that database transactions are performed concurrently without the concurrency violating the data integrity guarantees that no effect of committed transactions is lost, and no effect of aborted (rolled back) .

TỪ KHÓA LIÊN QUAN