情感障碍是什么| 痤疮是什么原因引起的| 怀孕一个月出血是什么情况| 福兮祸兮是什么意思| 心脏彩超主要检查什么| 醋粉是什么做的| 什么的时间| 动车与高铁有什么区别| 清真食品是什么意思| 坐月子什么不可以吃| 痛风喝什么茶最好| 甲醛中毒有什么症状| 为什么会乳糖不耐受| 腰椎盘突出挂什么科| 北齐是什么朝代| 拉肚子是什么原因导致的| 南京有什么美食| 91是什么| 孩子注意力不集中缺什么微量元素| 静脉血栓有什么症状| 溃疡是什么病| gly是什么氨基酸| 老烂腿抹什么药膏最好| 本能反应是什么意思| 什么东西养胃又治胃病| 新生儿为什么有黄疸| 梦见以前的朋友是什么意思| 今年什么时候过年| 脑梗看什么科| 花木兰代表什么生肖| 高烧不退有什么好办法| 阳气不足吃什么中成药| 回族不吃什么肉| 什么的脑袋| mpv什么意思| 农历五月二十八是什么日子| 灰指甲有什么特效药可以治好| 青少年耳鸣是什么原因引起的| 白醋泡脚有什么效果| 欧尼什么意思| 喉咙疼吃什么消炎药| 乱花渐欲迷人眼是什么意思| guess是什么品牌| 胃食管反流病吃什么药| 更年期吃什么药好| 干戈是什么意思| 血去掉一撇念什么| 反物质是什么东西| 补血吃什么最好最快| 大米粉做什么好吃| 9月15号是什么星座| aj是什么牌子| 维生素c弱阳性是什么意思| 红豆和什么搭配最好| 间接胆红素偏高吃什么药| 考教师编制需要什么条件| 蟾蜍吃什么| 冲击波治疗有什么效果| 李健是清华什么专业| approval是什么意思| 苏打水什么味道| 桂林有什么好玩的景点| 罗曼蒂克什么意思| 大便干结是什么原因| 冬至为什么吃水饺| e3是什么意思| 中指尖麻木是什么原因| 什么是醪糟| 什么是乌龙茶| 缺钾会有什么症状| 梦见杀狗是什么预兆| 送巧克力代表什么意思| 老是想咳嗽是什么原因| 消防队属于什么编制| 早些泄挂什么科| 三三两两是什么生肖| 舌头痛吃什么药| 什么呀| 未成年喝酒有什么危害| 同房出血是什么原因| 龟头炎的症状是什么样| 眩晕是什么原因引起的| 疖是什么意思| 下缘达宫颈内口是什么意思| 口苦口干是什么原因引起的| 透明人什么意思| 胆汁是什么| 贫血吃什么| 梦见掉头发是什么意思| 七月份适合种什么菜| 鲤鱼最爱吃什么食物| 补血吃什么最好最快| 低密度脂蛋白胆固醇高吃什么药| 吃黄芪有什么好处| 西洋参跟花旗参有什么区别| 每个月月经都提前是什么原因| 胃有幽门螺旋杆菌是什么症状| 经常头痛什么原因| 验孕棒一条杠什么意思| srpl是什么药| 母亲节送给妈妈什么礼物好| 怀孕初期应该注意什么| 碘化银什么颜色| 1.8是什么星座| 灰姑娘叫什么名字| 3.1415926是什么意思| 55年出生属什么| 人参长什么样子图片| 吃了鸡蛋不能吃什么| 第二职业干点什么好呢| 悟性是什么意思| 呼吸有异味是什么原因| 梦见别人开车撞死人是什么意思| 酸菜鱼用什么鱼| 胆固醇高吃什么最好| 尿频尿急尿不尽挂什么科| acb是什么意思| 红脸代表什么| 舌头白是什么原因| 月牙代表什么意思| 核桃不能和什么一起吃| 白子是什么| 抑菌液有什么作用| 症候群什么意思| 肾功能不全有什么症状| zoom 是什么意思| 大拇指旁边是什么指| 肾结石吃什么水果| 梦见一个人死了是什么意思| 合成立方氧化锆是什么| 梦见鸡啄我是什么意思| 荨麻疹什么原因引起的| 多囊卵巢综合症吃什么食物好| 吃阿司匹林有什么副作用| kbs是什么意思| 梦见大青蛇是什么预兆| 翡翠是什么意思| 带黄金对身体有什么好处| 孩子半夜咳嗽是什么原因| 长期喝山楂水有什么好处和坏处| 什么时候是排卵期| 中暑的症状是什么| 双环征是什么意思| 什么的藤| 舌头干是什么原因| 高密度脂蛋白胆固醇偏高是什么意思| 不为良相便为良医是什么意思| 机械油污用什么能洗掉| 下海是什么意思| 彪悍是什么意思| 骨骼肌率是什么意思| 午餐吃什么好又能减肥| 房子什么朝向好| 公立医院和私立医院有什么区别| 瘿病是什么病| 右佐匹克隆是什么药| 十月7号是什么星座| 1996年出生属什么生肖| 结婚5年是什么婚| 射手是什么象星座| 白醋加盐洗脸有什么好处| 10点是什么时辰| 空亡什么意思| 鹿晗的原名叫什么| 涂素颜霜之前要涂什么| 日本豆腐是什么材料| 1月27日是什么星座| 油皮适合用什么护肤品| 梦见买床是什么意思| 刘邦和刘备是什么关系| 佛珠生菇讲述什么道理| 小孩耳鸣是什么原因引起的| 为什么老是胃胀气| 糖尿病是什么原因造成的| 幡是什么意思| 肌酐测定是查什么| 女人耳垂大厚代表什么| 什么什么多彩| 丧偶式婚姻是什么意思| 珍珠状丘疹用什么药膏| ige是什么| 黑鱼不能和什么一起吃| 吃什么减肥效果最好| 心电图窦性心动过缓是什么意思| 筷子买什么材质的好| 扁桃是什么水果| 雪村和赵英俊什么关系| 敲木鱼是什么意思| 竹荪是什么| 半夜吃什么不会胖| 精液发黄是什么原因引起的| 沉香有什么好处| 99年属兔的是什么命| 哺乳期可以喝什么饮料| 薤是什么菜图片| 产妇吃什么下奶快又多又营养| 黑色素痣挂什么科| perrier是什么水| 黄历今天是什么日子| 五香粉是什么| 5月20日什么星座| 堪称什么意思| 弱精症有什么症状表现| 肾萎缩是什么原因引起的| 女性胆囊炎有什么症状| 公安局属于什么机关| 儿童早餐吃什么有营养还能长高| 梦见自己疯了什么意思| 破伤风针什么时候打| 老豆腐和嫩豆腐有什么区别| 不完全性右束支阻滞是什么意思| 太原有什么特产| 5月28日是什么星座| 来大姨妈喝酒有什么影响| 黄芪丹参山楂泡水有什么功效| 男士蛋皮痒用什么药| 小腿肌肉疼是什么原因| 高足是什么意思| 妊娠是什么| 知青为什么要下乡| 湿疹是什么皮肤病| 舌头发白什么原因| 不含而立是什么意思| 总胆红素高是什么病| 苹果熬水喝有什么功效| 脚脖子粗是什么原因| 阴道口瘙痒是什么原因| 吃糖醋蒜有什么好处和坏处| 呆呆的笑是什么笑| 儿茶是什么中药| 喉咙肿痛吃什么药| 皇太极叫什么名字| 秦始皇为什么叫祖龙| 藏毛窦挂什么科| 氧气湿化瓶里加什么水| 气管炎吃什么药最有效| 大便有血是什么原因男性| 十一月十七日是什么星座| 招商是什么工作| 什么是用户名| 长沙有什么大学| 第二名叫什么| ACEI是什么药| 韭菜什么人不能吃| 什么球会自己长大| 包皮是什么样子的| 王毅什么级别| 做肉丸用什么淀粉最佳| 脸基尼是什么意思| 什么是胶原蛋白| 人心隔肚皮什么意思| 什么是肺结核| 医生为什么穿白大褂| 腹肌不对称是什么原因| 早泄吃什么药最好| 祛痣挂什么科| 清华大学是什么级别| 痔疮手术后可以吃什么水果| 艺五行属性是什么| 经期吃什么食物比较好| darker是什么意思| 肝郁脾虚吃什么药效果最好| 牙疼喝什么药| 浅是什么意思| 百度Jump to content

get√新技能到店砍价的正确姿势

From Wikipedia, the free encyclopedia
(Redirected from ACID (computer science))
百度 报告指出:一带一路为澳中两国经贸发展描绘了美好的蓝图,能进一步增强双方互惠互利的合作伙伴关系。

In computer science, ACID (atomicity, consistency, isolation, durability) is a set of properties of database transactions intended to guarantee data validity despite errors, power failures, and other mishaps. In the context of databases, a sequence of database operations that satisfies the ACID properties (which can be perceived as a single logical operation on the data) is called a transaction. For example, a transfer of funds from one bank account to another, even involving multiple changes such as debiting one account and crediting another, is a single transaction.

In 1983,[1] Andreas Reuter and Theo H?rder coined the acronym ACID, building on earlier work by Jim Gray[2] who named atomicity, consistency, and durability, but not isolation, when characterizing the transaction concept. These four properties are the major guarantees of the transaction paradigm, which has influenced many aspects of development in database systems.

According to Gray and Reuter, the IBM Information Management System supported ACID transactions as early as 1973 (although the acronym was created later).[3]

BASE stands for basically available, soft state, and eventually consistent: the acronym highlights that BASE is opposite of ACID, like their chemical equivalents.[4] ACID databases prioritize consistency over availability — the whole transaction fails if an error occurs in any step within the transaction; in contrast, BASE databases prioritize availability over consistency: instead of failing the transaction, users can access inconsistent data temporarily: data consistency is achieved, but not immediately.[5]

Characteristics

[edit]

The characteristics of these four properties as defined by Reuter and H?rder are as follows:

Atomicity

[edit]

Transactions are often composed of multiple statements. Atomicity guarantees that each transaction is treated as a single "unit", which either succeeds completely or fails completely: if any of the statements constituting a transaction fails to complete, the entire transaction fails and the database is left unchanged. An atomic system must guarantee atomicity in each and every situation, including power failures, errors, and crashes.[6] A guarantee of atomicity prevents updates to the database from occurring only partially, which can cause greater problems than rejecting the whole series outright. As a consequence, the transaction cannot be observed to be in progress by another database client. At one moment in time, it has not yet happened, and at the next, it has already occurred in whole (or nothing happened if the transaction was cancelled in progress).

Consistency

[edit]

Consistency ensures that a transaction can only bring the database from one consistent state to another, preserving database invariants: any data written to the database must be valid according to all defined rules, including constraints, cascades, triggers, and any combination thereof. This prevents database corruption by an illegal transaction. An example of a database invariant is referential integrity, which guarantees the primary keyforeign key relationship.[7]

Isolation

[edit]

Transactions are often executed concurrently (e.g., multiple transactions reading and writing to a table at the same time). Isolation ensures that concurrent execution of transactions leaves the database in the same state that would have been obtained if the transactions were executed sequentially. Isolation is the main goal of concurrency control; depending on the isolation level used, the effects of an incomplete transaction might not be visible to other transactions.[8]

Durability

[edit]

Durability guarantees that once a transaction has been committed, it will remain committed even in the case of a system failure (e.g., power outage or crash). This usually means that completed transactions (or their effects) are recorded in non-volatile memory.[9]

Examples

[edit]

The following examples further illustrate the ACID properties. In these examples, the database table has two columns, A and B. An integrity constraint requires that the value in A and the value in B must sum to 100. The following SQL code creates a table as described above:

CREATE TABLE acidtest (A INTEGER, B INTEGER, CHECK (A + B = 100));

Atomicity

[edit]

Atomicity is the guarantee that series of database operations in an atomic transaction will either all occur (a successful operation), or none will occur (an unsuccessful operation). The series of operations cannot be separated with only some of them being executed, which makes the series of operations "indivisible". A guarantee of atomicity prevents updates to the database from occurring only partially, which can cause greater problems than rejecting the whole series outright. In other words, atomicity means indivisibility and irreducibility.[10] Alternatively, we may say that a logical transaction may be composed of several physical transactions. Unless and until all component physical transactions are executed, the logical transaction will not have occurred.

An example of an atomic transaction is a monetary transfer from bank account A to account B. It consists of two operations, withdrawing the money from account A and depositing it to account B. We would not want to see the amount removed from account A before we are sure it has also been transferred into account B. Performing these operations in an atomic transaction ensures that the database remains in a consistent state, that is, money is neither debited nor credited if either of those two operations fails.[11]

Consistency failure

[edit]

Consistency is a very general term, which demands that the data must meet all validation rules. In the previous example, the validation is a requirement that A + B = 100. All validation rules must be checked to ensure consistency. Assume that a transaction attempts to subtract 10 from A without altering B. Because consistency is checked after each transaction, it is known that A + B = 100 before the transaction begins. If the transaction removes 10 from A successfully, atomicity will be achieved. However, a validation check will show that A + B = 90, which is inconsistent with the rules of the database. The entire transaction must be canceled and the affected rows rolled back to their pre-transaction state. If there had been other constraints, triggers, or cascades, every single change operation would have been checked in the same way as above before the transaction was committed. Similar issues may arise with other constraints. We may have required the data types of both A and B to be integers. If we were then to enter, say, the value 13.5 for A, the transaction will be canceled, or the system may give rise to an alert in the form of a trigger (if/when the trigger has been written to this effect). Another example would be integrity constraints, which would not allow us to delete a row in one table whose primary key is referred to by at least one foreign key in other tables.

Isolation failure

[edit]

To demonstrate isolation, we assume two transactions execute at the same time, each attempting to modify the same data. One of the two must wait until the other completes in order to maintain isolation.

Consider two transactions:

  • T1 transfers 10 from A to B.
  • T2 transfers 20 from B to A.

Combined, there are four actions:

  1. T1 subtracts 10 from A.
  2. T1 adds 10 to B.
  3. T2 subtracts 20 from B.
  4. T2 adds 20 to A.

If these operations are performed in order, isolation is maintained, although T2 must wait. Consider what happens if T1 fails halfway through. The database eliminates T1's effects, and T2 sees only valid data.

By interleaving the transactions, the actual order of actions might be:

  1. T1 subtracts 10 from A.
  2. T2 subtracts 20 from B.
  3. T2 adds 20 to A.
  4. T1 adds 10 to B.

Again, consider what happens if T1 fails while modifying B in Step 4. By the time T1 fails, T2 has already modified A; it cannot be restored to the value it had before T1 without leaving an invalid database. This is known as a write-write contention,[12] because two transactions attempted to write to the same data field. In a typical system, the problem would be resolved by reverting to the last known good state, canceling the failed transaction T1, and restarting the interrupted transaction T2 from the good state.

Durability failure

[edit]

Consider a transaction that transfers 10 from A to B. First, it removes 10 from A, then it adds 10 to B. At this point, the user is told the transaction was a success. However, the changes are still queued in the disk buffer waiting to be committed to disk. Power fails and the changes are lost, but the user assumes (understandably) that the changes persist.

Implementation

[edit]

Processing a transaction often requires a sequence of operations that is subject to failure for a number of reasons. For instance, the system may have no room left on its disk drives, or it may have used up its allocated CPU time. There are two popular families of techniques: write-ahead logging and shadow paging. In both cases, locks must be acquired on all information to be updated, and depending on the level of isolation, possibly on all data that may be read as well. In write ahead logging, durability is guaranteed by writing the prospective change to a persistent log before changing the database. That allows the database to return to a consistent state in the event of a crash. In shadowing, updates are applied to a partial copy of the database, and the new copy is activated when the transaction commits.

Locking vs. multiversioning

[edit]

Many databases rely upon locking to provide ACID capabilities. Locking means that the transaction marks the data that it accesses so that the DBMS knows not to allow other transactions to modify it until the first transaction succeeds or fails. The lock must always be acquired before processing data, including data that is read but not modified. Non-trivial transactions typically require a large number of locks, resulting in substantial overhead as well as blocking other transactions. For example, if user A is running a transaction that has to read a row of data that user B wants to modify, user B must wait until user A's transaction completes. Two-phase locking is often applied to guarantee full isolation.

An alternative to locking is multiversion concurrency control, in which the database provides each reading transaction the prior, unmodified version of data that is being modified by another active transaction. This allows readers to operate without acquiring locks, i.e., writing transactions do not block reading transactions, and readers do not block writers. Going back to the example, when user A's transaction requests data that user B is modifying, the database provides A with the version of that data that existed when user B started his transaction. User A gets a consistent view of the database even if other users are changing data. One implementation, namely snapshot isolation, relaxes the isolation property.

Distributed transactions

[edit]

Guaranteeing ACID properties in a distributed transaction across a distributed database, where no single node is responsible for all data affecting a transaction, presents additional complications. Network connections might fail, or one node might successfully complete its part of the transaction and then be required to roll back its changes because of a failure on another node. The two-phase commit protocol (not to be confused with two-phase locking) provides atomicity for distributed transactions to ensure that each participant in the transaction agrees on whether the transaction should be committed or not.[13] Briefly, in the first phase, one node (the coordinator) interrogates the other nodes (the participants), and only when all reply that they are prepared does the coordinator, in the second phase, formalize the transaction.

See also

[edit]

References

[edit]
  1. ^ Haerder, T.; Reuter, A. (1983). "Principles of transaction-oriented database recovery". ACM Computing Surveys. 15 (4): 287. doi:10.1145/289.291. S2CID 207235758.
  2. ^ Gray, Jim (September 1981). "The Transaction Concept: Virtues and Limitations" (PDF). Proceedings of the 7th International Conference on Very Large Databases. Cupertino, California: Tandem Computers. pp. 144–154. Retrieved March 27, 2015.
  3. ^ Gray, Jim; Reuter, Andreas (1993). Distributed Transaction Processing: Concepts and Techniques. Morgan Kaufmann. ISBN 1-55860-190-2.
  4. ^ "ACID vs BASE Databases - Difference Between Databases - AWS". Amazon Web Services, Inc. Retrieved 2025-08-06.
  5. ^ "ACID vs BASE Databases - Difference Between Databases - AWS". Amazon Web Services, Inc. Retrieved 2025-08-06.
  6. ^ "Atomic operation". webopedia.com. Webopedia. 25 November 2003. Retrieved 2025-08-06. An operation during which a processor can simultaneously read a location and write it in the same bus operation. This prevents any other processor or I/O device from writing or reading memory until the operation is complete.
  7. ^ C. J. Date, "SQL and Relational Theory: How to Write Accurate SQL Code 2nd edition", O'reilly Media, Inc., 2012, p. 180.
  8. ^ Archiveddocs (2025-08-06). "Isolation Levels in the Database Engine". learn.microsoft.com. Retrieved 2025-08-06.
  9. ^ Silberschatz, Abraham; Korth, Henry F.; Sudarshan, S. (2011). "Transactions". Database system concepts (6th ed.). New York: McGraw-Hill. p. 631. ISBN 978-0-07-352332-3. OCLC 436031093.
  10. ^ "Atomicity". docs.oracle.com. Retrieved 2025-08-06.
  11. ^ Amsterdam, Jonathan. "Atomic File Transactions, Part 1". O'Reilly. Archived from the original on 2025-08-06. Retrieved 2025-08-06.
  12. ^ Silberschatz, Abraham; Korth, Henry F.; Sudarshan, S. (2011). "Advanced Application Development". Database system concepts (6th ed.). New York: McGraw-Hill. p. 1042. ISBN 978-0-07-352332-3. OCLC 436031093.
  13. ^ Bernstein, Philip A.; Newcomer, Eric (2009). "Chapter 8". Principles of Transaction Processing (2nd ed.). Morgan Kaufmann (Elsevier). ISBN 978-1-55860-623-4. Archived from the original on 2025-08-06.
带银饰有什么好处 什么什么的眼睛 灰色地带是什么意思 飘飘然是什么意思 viola是什么意思
发芽土豆含有什么毒素 小青柑属于什么茶 中毒了吃什么解毒 世界上最多笔画的字是什么 翰字五行属什么
七月生日是什么星座 早孕试纸和验孕棒有什么区别 为什么会有鼻屎 豕是什么动物 行长是什么级别
白衬衫配什么裤子好看 1975属什么生肖 女人喝蜂蜜水有什么好处 照看是什么意思 暖寿是什么意思
50岁是什么之年hcv9jop8ns0r.cn 为什么牛肝便宜没人吃hcv8jop5ns8r.cn 吃什么会回奶hcv7jop4ns6r.cn 腮帮子疼吃什么药hcv9jop7ns1r.cn 睡美人最怕什么脑筋急转弯hcv8jop0ns9r.cn
宇字属于五行属什么baiqunet.com 长长的什么hcv8jop9ns8r.cn 为什么qqhcv9jop4ns9r.cn cici什么意思hcv8jop8ns3r.cn 为什么香蕉不能放冰箱hcv9jop0ns3r.cn
拉黑色大便是什么原因hcv8jop5ns2r.cn pickup是什么意思hcv8jop4ns8r.cn pck是什么意思hcv9jop3ns4r.cn 蓁字五行属什么hcv8jop3ns7r.cn 丝瓜不可以和什么一起吃hcv8jop4ns7r.cn
完谷不化吃什么中成药cl108k.com 看鼻子挂什么科hcv9jop0ns7r.cn 鲁迅原名什么hcv9jop1ns5r.cn 不动产权是什么意思cj623037.com 膝盖疼痛是什么原因hcv8jop8ns5r.cn
百度