0

I want to recreate a dirty read anomaly with two independent transactions. I've started the terminal twice and connected both with my database. I've started the transaction with the command start transaction; in both. Then I updated one information in the first terminal window and this is what it showed me: Rows matched: 1 Changed: 1 Warnings: 0. After selecting all data in this table the change was there. But as I tried to show the changed data select * from adress; in the second terminal window, it didn't show me the change but the old data.

In the end I need to prove the dirty read anomaly and avoid this happening with the right isolation level.

Here are two screenshots of my terminal windows.

Transaction 1:

transaction 1

Transaction 2:

transaction 2

What am I doing wrong?

Thanks for the help, Robin

Community
  • 1
  • 1
iamrobin.
  • 1,554
  • 3
  • 19
  • 31
  • Did you commit your transaction in the first terminal? – Richard St-Cyr Dec 10 '15 at 14:33
  • I just tried it with commit in the first terminal. The second terminal still shows the old data. Only when I commit the second terminal also the data is the same. Does it also mean that both of the transactions are over? – iamrobin. Dec 10 '15 at 14:52

1 Answers1

0

You need to commit the changes on your first transaction

https://dev.mysql.com/doc/refman/5.7/en/commit.html

The idea of a transaction is to allow you to do a series of operations that either all must be successful, or they all mustn't happen.

Hope that helps.

Ajwhiteway
  • 986
  • 1
  • 9
  • 23