1 / 75

Distributed Transaction Management

Distributed Transaction Management. Jyrki Nummenmaa jyrki.nummenmaa@cs.uta.fi. Motivation. We will pick up some motivating examples from the world of electronic commerce .

noma noma
Download Presentation

Distributed Transaction Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Distributed Transaction Management Jyrki Nummenmaa jyrki.nummenmaa@cs.uta.fi

  2. Motivation • We will pick up some motivating examples from the world of electronic commerce. • As we will see, electronic commerce is an application area, where transactionality is needed, and the application programmers in charge of this need good knowledge on distributed transactions. • The following slides will explain discuss those examples and some of their implications.

  3. Electronic commerce -business-to-customer services • Searching for product information • Ordering products • Paying for goods and services • Providing online customer service • Delivering services • Various other business-to-business services exist, but these are enough for our motivational purposes...

  4. Internet Commerce • A person, running a web browser on a desktop computer, electronically purchases a set of goods or services from several vendors at different web sites. • This person wants either the complete set of purchases to go through, or none of them.

  5. PC Web browser Exhibitor Exhibition Hall’s Web site Brokerage service stands computers communications furniture Internet Commerce Example:Exhibition Hall Rental Companies’ Web Sites

  6. Technical Problems with Internet Commerce • Security • Failure • Multiple sites • Protocol problems • Server product limitations • Response time • Heterogeneous systems

  7. Failures: single computer • Hardware failure • Software crash • User switched off the PC • Active attack

  8. Failure: Additional Problems for Multiple Sites • Network failure • Or is it just congestion? • Or has the remote computer crashed? • Or is it just running slowly? • Message loss? • Denial-of-service attack? • Typically, these failures are partial.

  9. Distributed Transaction • A set of participating processes with local sub-transactions, distributed to a set of sites, perform a set of actions. • Server Autonomy - any server can unilaterally decide to abort the transaction. • All or none of the updates or related operations should be performed.

  10. Traditional data processing (database) transaction: set of read and update operations collectively transform the database from one consistent state to another. Electronic Commerce transaction: set of (any) operations collectively provide the user with his/her required package Subtle Difference: Transaction

  11. Distributed business object transaction example • Arriving to a football stadium with a car, the customer uses a mobile terminal to buy the ticket and get a parking place. • Business objects to • Charge the money from a bank account • Give access to parking • Entrance to stadium (writing tickets for collection at a collection point or just giving a digital reservation document).

  12. Distributed business object transaction example (cont’d) • Why is transactionality needed? • All-or-nothing situation? Maybe... • Compensational transactions are difficult - e.g. once access is given to car park, that is difficult to roll back. (Arriving to a football stadium…)

  13. Transaction properties -Atomicity • Atomicity • Ensures that if several different operations occur within a single transaction, it can never be the case that some operations complete if others cannot complete. • Classic example: transfer money from one bank account to another consisting of a withdraw and a deposit operations – we want both or neither.

  14. Transaction properties -Isolation • Isolation • Ensures that concurrently-executing transactions do not interfere with each other, in the sense that each transaction sees a consistent state of the data – often a database. • Prevents from using ”dirty data”. • Classic example (based on the previous one): The overall sum of money on the two bank accounts should not be summed while the txn is running).

  15. Transaction properties -Durability • Durability • Ensures that unless an update transaction is rolled back, then its changes will affect the state of the data as seen by subsequently-executing transactions. • Data is recorded persistently.

  16. Typical system architecture • Front-tier clients • e.g. web browsers. • Back-tier servers • such as database systems, message queue managers, device drivers, ... • Middle-tier business objects • each typically serving one client using (and locking) a number of shared resources from a number of back-tier servers.

  17. Traditional distributed DBMS system architecture • Computers are hard-wired to each other. • In practice a synchronous system, where a message timeout means that a computer has crashed. • A transparent centralised database management system, which the user can see as a single database. • An application program can use the database as a single database, thus benefitting from transparency.

  18. Main transactional services • Distributed locking is needed, if replicated data is needed for exclusive (write) access. • Distributed commit is needed to control the fate of the transaction in a controlled manner. • Barrier synchronisation can be used to guarantee a consistent view of the world.

  19. Implementing transactional services • As we noticed, a traditional distributed database system gives a transparent view to the system. It also takes care of concurrency. • In a modern distributed system, the application programmer needs to implement a large part of transactional services. • These services are complicated, and their implementation is far from being easy.

  20. Transaction Model - We will quite often write ”txn” instead of ”transaction”.

  21. Txn model - sites • We assume that there is a set of sitesS1,…,Sn. • All of these sites have a resource manager controlling the usage of the local resources. • We may know all of these sites before the txn starts (like a site for each bookstore sub-branch) or then we may not (like when previously unknown sites from the Internet may join in).

  22. Txn model - subtxns • The txn needs to access resources on some of these sites (without loss of generality, all of them). • For this, there is a local transaction on each site (transaction Ti on site Si). • The local transaction executes the operations required on the local site. • To use the local resources, the local transaction Ti on site Si talks with the local resource manager Mi.

  23. Distributed Transactions • In a distributed transaction there is a set of subtransactions T1,...,Tk, which are executed on sites S1,...,Sk. • Each subtransaction manages local resources. The particular problems of managing distributed transactions vs. centralised (local) transactions come from two sources: • Data may be replicated to several sites. Lock management of the replicated data is a particular problem. • Regardless of whether the data is replicated or not, there is a need to control the fate of the distributed transaction using a distributed commit protocol.

  24. Failure model - sites • Sites may fail by crashing, that is, they fail completely. • Sometimes it is assumed that crashed sites may recover. In this case usually the resource managers and the participants have recorded their actions in persistent memory. • Sometimes it is assumed that the crashed sites do not recover. • Usual assumption: if a site functions, it functions correctly (instead of e.g. sending erroneus messages).

  25. Failure model - messages • Messages may be delayed. • Message transfer delays are unpredictable (asynchronous message-passing) • Messages are transferred eventually. • Messages between sites are not spontaneously generated. • Messages do not change in transmission.

  26. Failure model - messages • All messages arriving at a site Si from a site Sj are processed in the order they were sent. • It may be that the network is partitioned, that is, some sites can not exchange messages. This may continue for an unpredictable time. • This assumption is by default avoided, since it is a really hard one. • We will state it explicitly if we want it to hold. • However, in real world this happens.

  27. Asynchronous communication • In a synchronous system, we assume that the relative speeds of processes and communication delays are bounded. • In an asynchronous system we do not make such an assumption. This means that not receiving an expected message does not mean a failure. • Generally, we assume here that we are dealing with an asynchronous system.

  28. Failure detection • Failure is hard to detect. • Typically, failure is assumed, if an expected message does not arrive within the usual time period. • Timeouts are used. • Delay may be caused by network congestion. • Or is the remote computer running slowly? • Mobile hosts make failure detection even harder, because it is expected behaviour if they stay unconnected for an unexpected time.

  29. Distributed Locking

  30. Mutual Exclusion (Locking) • The problem of managing access to a single, indivisible resource (e.g. a data item) that can only support one user (or transaction, or process, or thread, or whatever) at a time.

  31. Desired properties for solutions • Safety: Mutual exclusion is never violated. (Only one transaction gets the lock). • This property can not be compromised. • Liveness: Each request will be granted (eventually). • This property should not be compromised. • Fairness: Access to the resource should happen in the order of requests. • This property is to be discussed later.

  32. Coordinator-based solutions • There is a coordinator to control access. • Coordinator is a process on one of the sites. (It is none of the transactions.) • Let A be a data item. • When a transaction needs access, that transaction sends a request to coordinator. The request is X(A) = exclusively lock A. • The coordinator queues requests.

  33. Coordinator-based solutions • When the resource is available, the coordinator sends a grant message to the transaction T first in the queue. We write G(X(A)) = Grant X(A) • When T sees the grant message, it may use the resource. • When T does need the resource anymore, it sends a release message to the coordinator. R(A) = release A.

  34. An example T’’ T T’ C Lock request list X(A) - - T’’ T’’,T’ T’ - - X(A) G(X(A)) R(A) X(A) G(X(A)) R(A) G(X(A)) R(A)

  35. Coordinator-based solutions / properties • These coordinator-based solutions obviously have the safety and the liveness properties, if the coordinator is correctly implemented. • We can argue that they are also fair, since requests are queued. The ordering (and fairness) only takes place at the coordinators site (request arrival, not request departure). More on that later. • Since lock management is centralised, different lock types need no special attention.

  36. Coordinator-based solutions / weaknesses • The system does not tolerate a crashing coordinator. • The coordinator may become a bottleneck for performance. • Suppose data is replicated, there is a local copy, and the coordinator is not on the local site. Then we always need to communicate over the network, which reduces the benefits of having a local copy.

  37. Primary copy for replicated data • If data is not replicated, then to use a data item, you must contact the site containing the item. • If the resource manager at that site acts as the coordinator giving locks for its items, communication is simple. • If the data is replicated, then we can have a ”primary copy”, which is accessed for locking. The resource manager at the site of the primary copy is the coordinator.

  38. Token-based algorithms for resource management • In the token-based algorithms, there is a token to represent the permission. • Whoever has the token, has the permission, and can pass it on. • These algorithms are more suitable to share a resource like a printer, a car park gate, etc than for a huge database. Let’s see why…

  39. Perpetuum mobile • The token travels around (say, a ring). • When a process receives the token, it may use the resource, if it so wishes. • Then the process passes the token on. TOKEN

  40. Token-asking algorithms • The token does not travel around if it is not needed. • When a process needs the token, it asks for it. • Requests are queued.

  41. Analysis of token-based algorithms • Safety – ok. • Liveness – ok. • Fairness – in a way ok. • Drawbacks: • Token-based algorithms are vulnerable to single-site failures • Token management may be complicated and/or consume lots of resources, if there are lots of resources to be managed.

  42. Voting-based algorithms • We assume here that we know a set or resource managers (say, M1,…,Mn), which hold a replicated data item. • When transaction T needs access to the shared resource, it will send a message to M1,…,Mn asking for the permission. • Each M1,…,Mn will answer G(X(A)) meaning a Yes vote or N(X(A)) meaning a No vote. • T waits until the replies are in. • If there are enough Yes votes, T will get the lock.

  43. A voting example M1 T1 T2 M2 X(A) X(A) X(A) G(X(A)) G(X(A)) X(A) N(X(A)) N(X(A))

  44. How many votes you need? • Suppose we have n resource managers, and we want k Yes votes for an exclusive lock (write-lock) and m No votes for a shared lock (read-lock). • To avoid two simultaneous exclusive locks, we must have k > n/2. • To avoid simultaneously having an exclusive and a shared lock, must have k + m > n. • If read-operations dominate, then we may choose m=1 and k=n. • Notice that we may choose to consult more resource managers than the above minumum number.

  45. Which resource managers to consult? • In principle, it could be enough to ask only a subset (like a majority) of processes for a permission. • This subset could be statistically defined, given a data item. • However, as it might be advantageous to contact near-by resource managers, the set may well depend on who is asking.

  46. Example • Suppose we operate an airline with offices (and resource managers) in Tampere, Santiago de Chile and London. • It seems reasonable to replicate timetables and use m=1, k=n, since that information does not change that often. • For ticket booking, primary copy may be more appropriate. By statistical analysis we may get to know, where people (geographically) book which flights, to choose the placement of each primary copy.

  47. Who needs to give permission? • If we need a permission from all resource managers, then we do not tolerate site failures (all the downsides of having a coordinator plus all the extra effort of contacting all the resource managers). • Generally, a majority (of all resource managers) is enough. • There are also ways other than simple majority or unanimous vote, but one has to be careful to preserve the mutual exclusion.

  48. A problematic voting T2 T1 M1 M2 X(A) X(A) X(A) G(X(A)) R(A) G(X(A)) N(X(A)) X(A) N(X(A)) Now what?

  49. Analysis for voting • Safety • Apparently ok, if the numbers are chosen appropriately. • Liveness • This far there is nothing to stop the previous slide situation repeating over and over. • Liveness is not guaranteed unless we make some improvements. • Fairness • Nothing appears to guarantee fairness at this point. -> Further improvements are necessary.

  50. How to re-start after not getting a lock? • Apparently, something needs to be done to avoid repeating the situation where no-one gets the lock. • If we re-start requesting locks, we can tell younger transactions to wait longer before re-starting. • However, new transactions may always step in to stop the oldest transaction from getting the lock -> this is not the solution.

More Related

玻璃钢生产厂家德阳推荐成都商场美陈欧式玻璃钢雕塑怎么制作赣州玻璃钢雕塑优势泡沫雕塑跟玻璃钢区别杨浦区玻璃钢雕塑定制驻马店玻璃钢卡通雕塑厂家汕头玻璃钢动物雕塑现货玻璃钢雕塑哺乳图片菏泽玻璃钢雕塑价格安徽玻璃钢海豚雕塑定制玻璃钢人物雕塑哪家合适金刚大猩猩玻璃钢雕塑平顶山玻璃钢卡通雕塑延边公园玻璃钢雕塑兰州玻璃钢雕塑制作公司枣庄玻璃钢雕塑设计菜园玻璃钢花盆黄山玻璃钢雕塑工厂镜面玻璃钢仿铜雕塑制作厂家营口玻璃钢商场美陈性价比高的大型玻璃钢雕塑山西欧式玻璃钢雕塑定制西安欧式玻璃钢雕塑订做价格广场玻璃钢卡通雕塑供应商家广东人物玻璃钢雕塑公司低价玻璃钢雕塑焦作玻璃钢人物雕塑定做价格甘肃卡通玻璃钢雕塑制作山东玻璃钢牛动物雕塑小猪摆件长春市玻璃钢雕塑设计公司香港通过《维护国家安全条例》两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”19岁小伙救下5人后溺亡 多方发声单亲妈妈陷入热恋 14岁儿子报警汪小菲曝离婚始末遭遇山火的松茸之乡雅江山火三名扑火人员牺牲系谣言何赛飞追着代拍打萧美琴窜访捷克 外交部回应卫健委通报少年有偿捐血浆16次猝死手机成瘾是影响睡眠质量重要因素高校汽车撞人致3死16伤 司机系学生315晚会后胖东来又人满为患了小米汽车超级工厂正式揭幕中国拥有亿元资产的家庭达13.3万户周杰伦一审败诉网易男孩8年未见母亲被告知被遗忘许家印被限制高消费饲养员用铁锨驱打大熊猫被辞退男子被猫抓伤后确诊“猫抓病”特朗普无法缴纳4.54亿美元罚金倪萍分享减重40斤方法联合利华开始重组张家界的山上“长”满了韩国人?张立群任西安交通大学校长杨倩无缘巴黎奥运“重生之我在北大当嫡校长”黑马情侣提车了专访95后高颜值猪保姆考生莫言也上北大硕士复试名单了网友洛杉矶偶遇贾玲专家建议不必谈骨泥色变沉迷短剧的人就像掉进了杀猪盘奥巴马现身唐宁街 黑色着装引猜测七年后宇文玥被薅头发捞上岸事业单位女子向同事水杯投不明物质凯特王妃现身!外出购物视频曝光河南驻马店通报西平中学跳楼事件王树国卸任西安交大校长 师生送别恒大被罚41.75亿到底怎么缴男子被流浪猫绊倒 投喂者赔24万房客欠租失踪 房东直发愁西双版纳热带植物园回应蜉蝣大爆发钱人豪晒法院裁定实锤抄袭外国人感慨凌晨的中国很安全胖东来员工每周单休无小长假白宫:哈马斯三号人物被杀测试车高速逃费 小米:已补缴老人退休金被冒领16年 金额超20万

玻璃钢生产厂家 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化