回滚以实现原子性和持久性
我试图了解数据库事务的 ACID 属性:它们是如何实现的;哪一部分是原子性,哪一部分是持久性等。
假设我有一个包含两个操作的事务:A
和 B
。不幸的是,执行操作 B
时系统已关闭。系统重置后,我们知道数据库将保留(通过 sqlite 中的回滚旅程)执行操作 A 之前的状态。那么,这显示了哪种 ACID 属性,原子性还是持久性?
另一种情况:假设执行action B
时,发生错误并通知到应用程序,并回滚应用程序。我认为这是纯粹的原子性,是由用户实现的,而不是由数据库引擎实现的。我说得对吗?
I am trying to understand the ACID property of database transction: how they are achieved; which part is atomicity and which part is durability ,etc.
Let's say I have a transction with two actions,A
and B
. Unfortunately, system powered off when performing action B
. After a system reset, we know the database will preserve (through the rollback jounery in sqlite) the state before performing action A
. So, which ACID property does this show, atomicity or durability?
Another case :Suppose when performing action B
, an error happened and was notified to the applicaiton , and the application rollback. I consider this is as pure atomicity which is achieved by the user but not by the database engine. Am I correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这两个例子都强调了原子性:A 和 B 要么都提交,要么都不提交。
持久性是一个仅在事务提交之后才出现的属性。应用程序可以放心,如果 COMMIT 调用成功,那么它就是持久的。系统重置或断电不会恢复已提交事务的效果,因此具有持久性。
Both examples highlight atomicity: either both A and B are committed, or neither.
Durability is a property that comes into the picture only after the transaction is committed. The application can rest assured that if the COMMIT call succeeded, then is durable. A system reset or a power off will not revert the effect of a committed transaction, hence its durability.