Benpian begun to enter fields of study affairs. A transaction is an important concept in the field of the database, but is implemented in a mysql database and so on. Mysql but when they realize these concepts really are in accordance with the concept of a database subject areas to achieve it?
Domain knowledge of the transaction scope or design knowledge points more, the face of so much knowledge Nature must first be connected in series, so as not to get lost, so the first objective of this paper to do a series of knowledge. Secondly, a series of knowledge, do a rough sort. So Benpian the equivalent of a few opening words of the follow-up.
Well ado, enter the following topic.
Field matters, the first thought was definitely ACID
the four attributes, namely atomicity, consistency, isolation, durability.
The first important cognitive
ACID
Four attribute specification only requires a database to follow these norms. But the specific implementation, different databases did not entirely in accordance with the specification.
The second important cognitive
For example MVVC or redo log, undo log, locks, etc., to achieve these specifications they are born.
Let us look at innodb transaction in understanding the rules.
Atomic is the transaction as a whole, since it is a whole task, then the task will certainly be in two states: failure or success, there is no intermediate state.
The consistency in fact, is the business semantics of the application layer with the support of the transaction, to achieve a common database migration from one consistent state to another consistent state , more consistency is an attribute of the application layer.
Persistence is the transaction will be submitted to the permanent record in the database. Of course, if the memory device all bad, and that the persistent nature can not be guaranteed.
Finally, isolation and strict specification defines a firm changes made before committing to other transactions is not visible (these matters have access to the same records). 但是
In innodb side, it is weak isolation.
So, what is weak isolation it? This leads to the definition of the SQL standard 隔离级别
, namely: READ UNCOMMITTED (Uncommitted Read), READ COMMITTED (read committed), REPEATABLE READ (repeatable read), SERIALIZABLE (serializable).
Strict isolation specification, to the corresponding isolation level serializable (serial execution of concurrent transactions means that no competition for resources, i.e. poor performance means performs a complete re-executing another transaction).
Weak isolation, isolation it corresponds to the other three levels. And after considering the performance and isolation levels, in fact, it is commonly used isolation level: Read Committed (also known as non-repeatable read) and repeatable read.
Which refers to the submission read: a transaction before committing to any changes made to record, other transactions are visible.
Refers to a repeatable read: performing a transaction, the result of multiple reads of the same records are consistent.
Achieve repeatable read the lead MVVC 多版本并发控制
. Implementing transactions are also dependent on a variety 锁
.
Continue to look at these four properties, it depends on the realization of atoms Redo Log
and Undo Log
these logging mechanisms.
Persistent actually be associated with them, in addition to some other backup technology.
As for consistency, to some extent, the other three characteristics combine consistency is achieved.
summary
In summary, we can see that the transaction raises several important areas of knowledge, including MVVC, Redo / Undo, locks, other technologies (such as WAL etc.).
So, when the follow-up study of these concepts, it is more clear that they are here to solve any problem, what role.
Next, we see from the Redo Log.