Home > database >  Feel dirty read violates the transaction isolation, consult
Feel dirty read violates the transaction isolation, consult

Time:09-26

A transaction reads another transaction have not been submitted content, called dirty reads, but the transaction isolation in the definition is described as: "the current transaction does not see by another concurrent transaction is to modify the data,"

When dirty read, a transaction reads another transaction have not been submitted content, don't uncommitted content is another concurrent transactions is to modify the data? If not, the transaction isolation, how, what is "transaction is modify the data?

Self-study in Mysql, some abstract concept or some fuzzy, I hope you a glad guys,

CodePudding user response:

Some application when doing the some queries don't care about the accuracy of data and speed but relations, then use dirty read can become a kind of choice,

CodePudding user response:

reference 1st floor ACMAIN_CHM response:
some application when doing the some queries don't care about the accuracy of data and speed but relations, then use dirty read can become a kind of choice,


First of all thank you moderator answered, mentioned the need to choose according to the usage of specific data accuracy and speed of a balanced,

But I still have some concerns on the concept of, dirty reads is a violation of the transaction isolation, if it is, only to introduce the concept of transaction, looks has solved the problem of the dirty read, because the transaction isolation requires a transaction can't read the other transaction is to modify the data, that is not submitted data, understand it correctly?

CodePudding user response:

Suggested that the building looked the transaction isolation mode of several different and applicable range, otherwise don't know where about,

CodePudding user response:

See that the original poster?
About the transaction, a lot of code are finally judge whether operation is successful, success is submitted, no success, rollback,,
Why they don't directly submit? Must first have a rollback

CodePudding user response:


A transaction reads another transaction have not been submitted content, called dirty reads,

This problem is because there are no submissions, for example, A data field v, now there is A transaction A the v from 10 to 100, however, did not commit,

This time another transaction B if the value, which is 100, but this time, just the transaction A transaction rollback for other reasons,

So at this time of the transaction B read data is not accurate, this is the dirty reads,

, of course, if the transaction A finally submitted, the transaction B read and correct the data, but this is also A dirty read,

So dirty read and read the data correctly has nothing to do, just say read data is uncertain,

CodePudding user response:


In addition, in mysql is unable to read to the dirty data, because the myisam storage engine is table level lock, concurrency is very poor,

The innodb storage engine, support MVCC, multi version concurrency control, you read always submitted data,

But so did in oracle,

So can say now to reading dirty data, that only the SQL server, you can specify nolock in the query, or specify the isolation level for the read uncommitted, this is a dirty read, that is to say, can read uncommitted data, then the benefit is that don't need to read lock when reading data, so will not be modify data transaction,

CodePudding user response:

I have been don't understand the conceptual definition,

Transaction is modify data in A read the transaction B, the transaction A itself in violation of the principle of its own isolation, it is A transaction?

CodePudding user response:

Read the transaction data are modified in B, transaction isolation level for uncommitted (uncommited) read
so muchCmmited level not appear dirty read,

CodePudding user response:

Transaction isolation level

CodePudding user response:

Isolation of specific behavior depends on the isolation level is set, the default isolation level meet do not allow the dirty read, also is to satisfy we often see the transaction isolation of this sentence

CodePudding user response:

Submit success, don't rolled back, this is normal
Will tell from the internal implementation, write data, if some data is not legal, so is not successful, not rollback is also submitted?
(their control) from the perspective of business implementation, if some of the data does not meet the business rules, don't you also submit? Or whether in line with the business rules, you can just write the data into it?

CodePudding user response:

Or you will think of business judgment rule first, does not meet the conditions do not write, but it is a kind of implementation method of representative writing data, not all can always use this way

CodePudding user response:

The original poster can learn the concept of isolation level,

Different requirements need different isolation level, the lowest level of isolation level support dirty reads, higher isolation level does not support dirty reads,

CodePudding user response:

Transaction isolation is not: transaction to modify A, B can't see,
This sentence is only one transaction isolation level of isolation,
Any violation of the isolation is A fallacy, the lowest layer of isolation level, A transaction to modify, B of course to see!

CodePudding user response:

This kind of violation as long as does not affect the normal processing of the business, is it doesn't matter
As to whether can affect the normal processing of the business, need to particular case is particular analysis
Have a BBS, for example, a person in the hair stick son, to update the person posts after Posting the ah, the last activity time, COINS and so on clutter, and possibly update global BBS post number, we can think of these as a transaction, in addition there is a need to read all posts on the same day, this does not need to run in the affairs read again, dirty read the result can meet the needs of us, we can use dirty read under this scenario, if the transaction isolation completely, because may also have a lot of people in the post, will affect the efficiency of reading

CodePudding user response:

refer to 6th floor yupeigu response:
in addition, in mysql is unable to read to the dirty data, because the myisam storage engine is table level lock, concurrency is very poor,

The innodb storage engine, support MVCC, multi version concurrency control, you read always submitted data,

But so did in oracle,

So can say now to reading dirty data, that only the SQL server, you can specify nolock in the query, or specify the isolation level for the read uncommitted, this is a dirty read, that is to say, can read uncommitted data, then the benefit is that don't need to read lock when reading data, so will not be modify data transaction locking,


How to implement a read transaction in mysql "uncommitted" data?
The Read Uncommitted Read Uncommitted level can be achieved?
SET the SESSION TRANSACTION ISOLATION LEVEL the READ UNCOMMITTED.