Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Does virtual reading mean unrepeatable?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

The purpose of this article is to share with you the meaning that virtual reading is unrepeatable. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Virtual reading is different from unrepeatable reading.

Dirty read dirty reads: this event occurs when a transaction reads data that has not yet been committed. For example: Transaction 1 modifies a row of data, and then Transaction 2 reads the modified row before Transaction 1 commits the modification operation. If Transaction 1 rolls back the modification operation, then the data read by Transaction 2 can be treated as if it never existed.

Non-repeatable read non-repeatable reads: this event occurs when a transaction reads the same row of data twice, but gets different data each time. For example, Transaction 1 reads a row of data, and then Transaction 2 modifies or deletes the row and submits the modification operation. When Transaction 1 tries to reread the row, it gets a different data value (if the row is updated) or finds that the row no longer exists (if the row is deleted).

Virtual read phantom read: this event occurs if a row of data that meets the search criteria appears in a subsequent read operation, but that row of data does not belong to the original data. For example: Transaction 1 reads some rows that meet some search criteria, and then Transaction 2 inserts a new row that meets the search criteria of Transaction 1. If Transaction 1 re-executes the query that produced those rows, you will get different rows.

The transaction scenario looks like this:

For the same bank account A has 200 yuan, A carries on the withdrawal operation 100 yuan, B carries on the transfer operation 100 yuan to the B account. If the transaction is not quarantined, the following problems may occur:

1. The first kind of missing update: first of all, there are 200 yuan in the account when A withdraws, and 200 yuan is also transferred to B at the same time, and then An and B operate at the same time, A successfully withdraws 100 yuan, B fails to roll back, and the account is finally 200 yuan. In this way, the operation of An is covered, and the bank loses 100 yuan.

2, dirty reading: a withdraws 100 yuan not submitted, B carries on the transfer to check that there is 100 yuan left in the account, this is An abandoned operation rollback, B normal operation submission, the final account is 0 yuan, B read A's dirty data, the customer lost 100 yuan.

3, virtual reading: similar to dirty reading, it is aimed at the reading problem in the process of insertion operation, such as 100 yuan of deposit C has not been submitted, then the bank makes a statement to make a statistical inquiry account of 200 yuan, and then C submits it. At this time, the bank statistics found that the account is 300 yuan, which can not be judged in the end?

People seem to think that statistics must be updated from time to time, which is normal; but it is not normal if statistics are in a transaction. for example, one of our statistical applications needs to output the statistical results to the computer screen and to the disk file of a computer on the remote network, in order to

When we split the performance improvement and user response into two threads, the statistics completed first and later may be inconsistent, and we don't know which one will prevail.

4, can not be read repeatedly: both An and B start to check that the account is 200 yuan, and A begins to withdraw 100 yuan to submit. At this time, B makes another inquiry when preparing for the final update and finds that the result is 100 yuan. At this time, B will be very confused. I don't know whether to change the account to 100 or 0.

The difference between dirty reading and dirty reading is that dirty reading reads dirty data that has not been committed by the previous transaction, while unrepeatable reading is re-reading the committed data of the previous transaction.

5. The second type of missing update: it is a special case that cannot be read repeatedly. As above, B does not make a second query but operates directly, the final amount in the account is 100 yuan, the operation of An is covered, and the bank loses 100 yuan. It feels similar to the first type of missing update.

Does the above mean that virtual reading can not be repeated? the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report