数据库供应商如何实现交易?

时间:2022-09-30 12:34:15

When working with database it is often essential to use transactions. Say for example that I want to transfer a certain amount of money from account A to account B. This involves two queries:

使用数据库时,通常必须使用事务。比方说,我想将一定数量的资金从账户A转移到账户B.这涉及两个问题:

  • decrease the money in account A
  • 减少账户A的钱
  • increase it in account B.
  • 在帐户B中增加它

In theory I can make the queries separately, but errors happen. So, to be sure, I can pack the two queries inside a transaction and be sure that either both operations end regularly or nothing has changed at all. No money disappears or is created.

从理论上讲,我可以单独进行查询,但会发生错误。因此,可以肯定的是,我可以在事务中打包两个查询,并确保两个操作都定期结束或根本没有任何更改。没有钱消失或被创造。

The problem is that it seems to me that this only shifts the responsibility from me to the database vendor. Now it is up to the database to make both operations and be sure that either both are made or nothing has changed. And the database developers face the same problems that errors happen.

问题是,在我看来,这只会将责任从我转移到数据库供应商。现在由数据库来完成两个操作,并确保两者都已完成或没有任何更改。数据库开发人员面临着发生错误的相同问题。

What techniques do database vendors use to ensure safety for transactions?

数据库供应商使用哪些技术来确保交易的安全性?

2 个解决方案

#1


8  

The ACID - Implementations page on wikipedia will get you started on write-ahead logging, shadow paging and multi-version concurrency control. Follow the links to find more.

*上的ACID - Implementations页面将帮助您开始预写日志记录,影子分页和多版本并发控制。点击链接查找更多信息。

Each DBMS vendor implements their own algorithms, often several different ones depending on the context, full ACID or relaxed requirements, distributed transaction consistency requirements etc...

每个DBMS供应商都实现自己的算法,通常是几个不同的算法,具体取决于上下文,完整的ACID或宽松的要求,分布式事务一致性要求等......

#2


3  

write ahead logs.

提前写日志。

#1


8  

The ACID - Implementations page on wikipedia will get you started on write-ahead logging, shadow paging and multi-version concurrency control. Follow the links to find more.

*上的ACID - Implementations页面将帮助您开始预写日志记录,影子分页和多版本并发控制。点击链接查找更多信息。

Each DBMS vendor implements their own algorithms, often several different ones depending on the context, full ACID or relaxed requirements, distributed transaction consistency requirements etc...

每个DBMS供应商都实现自己的算法,通常是几个不同的算法,具体取决于上下文,完整的ACID或宽松的要求,分布式事务一致性要求等......

#2


3  

write ahead logs.

提前写日志。