Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Transaction
Management COMP9311 23T2; Week 8.1 1 Some Announcements Project due last week. Assignment 2 will be released this week. Exam Schedule will be released soon (likely on 18 Aug Morning) 2 Transaction A transaction is a unit of program execution that accesses and possibly updates various data items. E.g., transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – 50 3. write(A) 4. read(B) 5. B := B + 50 6. write(B) Two main issues to deal with: ◦ Failures of various kinds, such as hardware failures and system crashes ◦ Concurrent execution of multiple transactions 3 Issue (1) Concurrent execution of multiple transactions is needed ◦ Why? i. Multiple users/transactions may read/change the same data ii. Allowing multiple transactions to update data concurrently can result in complications - data inconsistency. ◦ Therefore transaction processing systems... i. need to support multiple transactions at the same time. ii. usually allow multiple transactions to run concurrently. 4 Issue (2) Failures of various kinds a. System failure: i. Disk failure - e.g., head crash, media fault. ii. System crash - e.g., unexpected failure requiring a reboot. b. Program error: i. e.g., divide by zero. c. Exception conditions: i. e.g., no seats for your reservation. d. Concurrency control: i. e.g., deadlock, expired locks. Transaction Processing Systems need to be robust against failure 5 Example of Fund Transfer (1) A transaction is a unit of program execution that accesses and possibly updates various data items. Example: A possible transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – 50 3. write(A) 4. read(B) 5. B := B + 50 6. write(B) 6 Each transaction typically includes some database access operations Operations relevant to transaction processing: 1. Read 2. Write 3. Computation Example of Fund Transfer (2) Atomicity requirement ◦ If the transaction fails after step 3 and before step 6, money will be “lost” leading to an inconsistent database state ◦ Failure could be due to software or hardware ◦ The system should ensure that updates of a partially executed transaction are not reflected in the database (all-or-nothing) Example: Transaction to transfer $50 from account A to account B: 1. read(A) 2. A := A – 50 3. write(A) 4. read(B) 5. B := B + 50 6. write(B)