Mysql innodb row lock doesn't work
Now, I think its problem is you should not use the transaction not started
that only make big different so, you should must START TRANSACTION
like my code, and
some times it was happens when in a running transaction
, two identical statements get different values, because some other transaction has modified the table’s rows.
like your as following as:
transaction1> START TRANSACTION;
transaction1> SELECT * FROM accounts WHERE id=1 FOR UPDATE;
For example:
transaction1> SELECT first_name, last_name FROM customer WHERE id = 3 FOR UPDATE;
+------------+-----------+
| first_name | last_name |
+------------+-----------+
| JMAIL | KRISH |
+------------+-----------+
1 row in set (0.00 sec)
you should refer this link:
http://www.mysqlperformanceblog.com/2012/03/27/innodbs-gap-locks/
http://dev.mysql.com/doc/refman/5.1/en/innodb-locks-set.html
https://stackoverflow.com/a/22007412/3242978