This is a chance to discover, even you feel unexpected ............ Background: 1. This dormitory bathroom 2. Card campus card and card reader (automatic induction) 3 The credit rules, put a cartoon card on the front of the card reader, automatically read 1 yuan in about 1 second, start water, every 4 seconds, 1 penny every 4 seconds. 1 yuan is all deducted or then swipe again, you can stop the bath water. The amount of consumption is based on the amount of reader deduction. Study: 2 different student cards in accordance with a certain order of card: I didn't think of these problems at around 13:00 noon, taking a shower as usual. Suddenly I feel that the classmates can't stop my water? I tried to play, the resulting billing displays the amount of the card from the classmate. I am a little uneasy, then open the faucet with my own card, the miracle appears, my card display amount is still the amount before I have just consumed. I am estimated that I have a card that I have just spended in my classmates. Then I thought that the inferior of dirty data for database operations. So I thought of the following strategy (guidance with dirty data): My card: A I use the faucet: L1 classmate's card: b classmates' faucet: L2 1. Use a card to flow water, start Fees, assume that there is 20 yuan on the card at this time. Start taking a bath. 2.05 of the money on the L1 remains about 0.05 (immediately stopping the water and billing the card A), and the L2 is opened with the A card, and then the L1 is quickly used. Then, close the L2 quickly. According to the problem of dirty data, you can know that at this time, the card reader actively participates in the billing, waiting for the billing, and the Update database is buckled. Thus, consumption on L1 is covered by the update of L2 from the database from the database. That is to say, the card reader rule of the card reader is to record the balance of the A card and start charging. The card will be deducted from the balance in the balance. Thus, the balance of L1 and L2 read cards should be the same, but 2 machine accounts are different, and dirty data is caused by the order of the write. 3. Use A to flow the L1, assume that only 1 yuan in B (less than 1 yuan cannot be read, otherwise it can be overdown, it seems that the designer thinks this). Use the B card to stop L1 water. At this point, L1 writes back A card data in the B card. Thereby, data is confusing, and can be used as a "good way" to increase the balance of the card. Unlike the above ideas, the reading and writing of the dirty data is to read and record a balance of A in L1 and calculate the balance in the second card, and write back to A as a strategy. Therefore, the B card is written back to the A card data. That is, it does not produce a phenomenon in 2. However, it is not possible to prove that the problem in 2 can be solved. RESULTS: Using a cartoon management device, querying and calculating the amount from the Internet, it is found that the entire consumption amount in the process of consumption at noon does not really decrease because of the trial. From the perspective of consumption, the number of card consumptions in the consumption process is not as usual, but the jumping 211 213 216 ........ It seems that the consumption does have a certain jump, but Why does the amount reduce or have a purposeful increase because of dirty data theory? After analyzing the database report, the data table is as follows:
2004/11/30 13:05:50 Card spending 2004/11/30 13:17:55 23.00 -0.79 22.21 Water control subsystem 220 normal 2004/11/30 13:00:23 card spending 2004/11/30 13 : 11: 12 24.02 -0.02 24.00 Water Control Subsystem 217 Normal 2004/11/30 13:00:19 Card Consumption 2004/11/30 13:11:08 23.60-0.58 23.02 Water Control Subsystem 216 Normal 2004/11 / 30 12:51:50 Card consumption 2004/11/30 13:02:45 24.62 -0.02 24.60 Water control subsystem 213 normal 2004/11/30 12:51:35 card spending 2004/11/30 13:02:30 24.85 -0.23 24.62 Water Control Subsystem 211 Normal 2004/11/30 12:51:13 Card Consumption 2004/11/30 13:02:09 24.00 -0.15 23.85 Water Control Subsystem 210 Normal 2004/11/30 12:49 : 51 card spending 2004/11/30 13:00:47 24.01 -0.01 24.00 Water control subsystem 208 normal 2004/11 12:48:43 card spending 2004/11/30 12:59:40 25.06 -0.05 25.01 Water control subsystem 205 normal 2004/11/30 12:47:37 card spending 2004/11/30 12:58:35 25.19 -0.13 25.06 Water control subsystem 203 normal 2004/11/30 12:44:18 card consumption 2004/11/30 12:55:18 25.48 -0.29 25.19 Water Control Subsystem 201 can see the data of data, but the total consumption has not changed. However, from the perspective of code, you can see that the consumption system is the main code, because the difference in different consumptions will generate differences, relying on this mechanism to complete the billing and the correct record of the card consumption order, avoid dirt data Read and write. However, from the other hand, it is not understood, and if there is no difference in the number of consumption, why can this look at the data item of the problem?
In this issue, we will further think that if the time is used as the master code, how should the 2 hours before and after consumption? If the consumption is from another consumption, what should I do? For example, use A to open L1 L2? These are not known.
However, there is a little bit of certain number of numbers in terms of billing machine, each consumption is different from the number of consumption machines, but this contradiction is that if I use B card to end the A card consumption, database will How to record data? But in any case, this inferred persuasion is the greatest.
There is also a phenomenon, that is, if you consume at noon, I will go to the restaurant. But your liquidation result should be in the afternoon to query, the latency at this time is likely to temporarily present the billing machine. So why don't you have a machine number inside when the UPDATE is getting up? How do you query and return the wrong operation after the error?
There may be many of the distributed systems, there are many strategies and mechanisms I have not learned. The so-called people have someone, there are mountains outside the mountain!