3

The practice exam that I have been given does not come with solutions, and I'm not sure if my answer to these questions are correct.

If a MYSQL is running at the read-committed isolation level, the auto commit mode is turned off, and the server allows multiple connections at the same time. The time window is indicated on the left side

1) In this circumstance, is there any anomaly happening in T1 or T2 if there is, what would be the anomaly type?

Time Frame    Transaction 1   Transaction 2
1             Read(X);        Read(Z);
2             X = X + 1 ;     Read(Y);
3             Update(X);      Y=Y-Z;
4             Commit;         Update(Y)
5                             Read(X)

My answer to question one was there was no anomaly as the transactions didn't effect the values that the other one was using.

2) Will there be an anomaly in any of the following transactions? If there will be, what is the anomaly type?

Time Frame    Transaction 1   Transaction 2
1             Read(X);    
2             Read(Y);        Read(X);
3             Insert_Into(X); Read(Y);
4             Commit;         Y = T + Y;
5                             Read(X);
6                             Update(Y);
7                             Commit;

My answer to question two was that it was Phantom Read, as it's occuring at the read-committed isolation level this is possible, and Transaction 1 alters X while it is being read by Transaction 2.

  • Does Read(X) mean to read row X? If so, then what does Insert_into(X) mean? If it means read some row from the table X, then it is imprecise. Do the reads have FOR UPDATE on them? Sloppy test. – Rick James Nov 2 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.