Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you use Transactions in MySQL, and if you use a recent version of MySQL (>5.1) the row locks will be set by simply making select queries in the targeted rows <strong>inside</strong> the transaction (and not before).</p> <p>Queries running in parallele will automatically wait until the end of the first transaction. Unless you make very long transaction this wait will not be very long, and the process will continue just after the first transaction ends. Unless your treatments takes more than 15s chances are that by aborting your transaction in case of lock, sending a response to your final user and redoing the transaction later, you will loose a loooot more time.</p> <p>MySQL has a timeout setting for the lock (<strong>lock wait timeout</strong>), you can maybe adjust this timeout to a quite low value (let's say 3s) and you'll get an exception if your lock wait is too long, then you'll have to abort your transaction, but by default let MySQL do the lock &amp; wait managment without breaking the transaction early in case of lock.</p> <p>Anyway you should have Exception catch loops for your application code to catch for these timeout and for deadlock detection exceptions as well. The classical thing that should be done is that case is restarting the whole transaction until it works but if you want you can as well abort the whole thing and tell you user he should wait (but in 90% of the cases, this is longer than redoing the transaction without taking the user interaction in consideration).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload