I am writing an application which shall track the financial transactions (as in a bank), to maintain the balance amount. I am using Denormalizing
technique to keep the performance in check(and not have to calculate the balance at runtime) as discussed Here and Here.
Now, I am facing a Race Condition
if two people simultaneously did a transaction related to same entity, the balance calculation as discussed above, shall return/set inconsistent data, as discussed Here and Here, And also as suggested in the answers..
I am going for Mysql Transactions
.
Now My question is,
What Happens to the other similar queries when a mysql Transaction is underway?
I wish to know if other transactions fail as in Error 500
or are they queued and executed, once the first transaction finishes.
I also need to know how to deal with the either result from the php
point of view.
And since these transactions are going to be an element of a larger set of operation in php with many prior insert
queries, should I also device a mechanism to roll-back those successfully executed queries too, since I want Atomicity
not only as in individual queries but also as in whole operation logic(php).
Edit 1 :- Also, if former is the case, should I check for the error, and wait a few second and try that specific transaction query again after some time?
Edit 2 :-
Also Mysql Triggers
is not an option for me.