Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Microsoft SQL Server wikipedia , lookup
Database model wikipedia , lookup
Clusterpoint wikipedia , lookup
Relational model wikipedia , lookup
Global serializability wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Object-relational impedance mismatch wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Commitment ordering wikipedia , lookup
Distributed Transactions 分布式事物 Transaction Processing 事务处理 Why Most of the information systems used in businesses are transaction based. The market for transaction processing is many tens of billions of dollars per year Not long ago, transaction processing was only used in large companies. This is no longer the case (CORBA, J2EE, WWW, Internet …) There are may standards (XA-interface, Java Transaction API (JTA), Java Transaction Service (JTS), Web Services Transaction (WS-Transaction)) Transaction processing has become a core distributed systems technology It is an accepted, proven and tested programming model and computing paradigm for complex applications. Transaction 事务 A transaction is a collection of actions that belong logically together 事务是一个逻辑上连接的行为集合 Example: Money transfer Withdraw amount X from account A Deposit amount X on account B Example Flight Reservation 预订机票实例 Relations: FLIGHTS(FNO, DATE, SEATSSOLD, CAPACITY) RESERVATION(FNO, DATE, NAME) BEGIN_TRANSACTION input(flight, name, date) EXEC SQL SELECT SEATSSOLD, CAPACITY INTO temp1, temp2 FROM FLIGHTS WHERE FNO=flight AND DATE = date if temp1 == temp2 ABORT_Transaction else EXEC SQL UPDATE FLIGHTS SET SEATSSOLD = SEATSSOLD + 1 WHERE FNO=fight AND DATE=date; EXEC SQL INSERT INTO RESERVATION values (flight,date,name) COMMIT_TRANSACTION Formalization central system 形式化中心系统 Let Oij(x) be either a read (ri) or write (wi) operation of transaction Ti on data item x OSi = ∪j Oij Ni ∈ {commit (c), abort (a)} Transaction Ti is a total order Ti = {Σi, <i} Σi = OSi ∪ Ni (alphabet) For any two operations Oij(x) and Oik(x) ∈ OSi, then either Oij(x) <i Oik(x) or Oik(x) <i Oij(x) (for reads rij(X) and rik(x) they could be executedconcurrently. ) For all Oij ∈ OSi, Oij <i Ni Example Consider the transaction Ti READ(X) READ(Y) X <- X + Y Write(X) Commit ri(x) ri(y) wi(x) ci Ri(X) Ri(Y) Wi(x) Ci Limitations 局限性 Inserts not well reflected. Insert into table xyz values (1,’abc’,3) Complex selects (joins or predicates not well reflected) SELECT * from xyz WHERE location = ‘Montreal’; Table, tuple, subset? Property of Transactions 事务属性 Atomicity原子性 All or nothing A transaction often involves several operations that are executed at different times. Return Commit to user: all updates are safely in the database Return Abort to user: none of the updates is reflected in the database Abort might be user-induced or system-induced Local Recovery: eliminating partial results Consistency 一致性 Transactions make mistakes (introduce negative salaries, etc.) Transaction consistency enforced by integrity constraints: Null constraints, Foreign keys, Triggers and assertions Integrity constraints act as filters determining whether a transaction is acceptable or not. Checked by the system, not by the programmer Property of Transactions Isolation独立性 Ensuring correct results even when there are many transactions being executed concurrently on the same data Execution of concurrent transactions controlled such that result the same as if executed serially Enforced by a concurrency control protocol Why is concurrent execution useful? Durability持久性 Committed updates persistent despite failures System crash / disk survives: Global recovery: make sure committed, and only committed data is on disk UNDO transactions that were in the middle of execution at time of crash (abort) REDO transactions that were committed before crash but for which updates might not be reflected in DB on disk Disk failure solved by replication: database backups, mirrored disks, etc. Durability often combined with availability: percentage of time a system can be used for its intended purpose Centralized Transaction Execution 集中交换处理 Distributed Transaction execution(homogenous) 分布式交换操作 Federated Databases 联邦数据库 Interface 界面 • Begin_Transaction() -> XID; • starts a new transaction and delivers a unique transaction ID XID. This identifier will be used in the other operations in the transaction. • Commit_Transaction(XID) -> (true, false); • ends a transaction: a TRUE return value indicates that the transaction has committed; a FALSE return value indicates that it has aborted. • Abort_Transaction(XID); • aborts the transaction. Transaction life histories 事务生命周期 Schedule 调度 Schedule: sequence of actions (read,write,commit,abort) from a set of transactions (which obeys the sequence of operations within a transaction) Reflects how the DBMS sees the execution of operations; ignores thing likereading/writing from OS files etc. Serial History 串行调度 Execution Schedule (History) 执行时间表 Serializability and Dependency Graphs串行和依赖图 Distributed Transaction Processing分布式事务处理 Global and local Histories 全局与本地史 Independent Execution 独立执行 Concurrency Control: Locking 并发控制:死锁 Two-phase locking (2PL) 两相锁(两段锁) Example Centralized 2PL 集中两段锁 Distributed 2PL 分布式两段锁 Deadlocks 死锁 Dependency graph - wait-forgraph 依赖图-等待forgraph Deadlock Detection (Continued) 僵局检测(续) Deadlock in distributed system 分布式系统死锁 Edge chasing