Table account have special field 'executor' for daemons to know that account is blocked for update with one of daemons.
Step by step:
- start transaction
block account with:
UPDATE `account` SET `executor` = 2727 WHERE `executor` is NULL AND `id` = 1234;
some operations. During this step another daemons can select row with id=1234 and try to update it(or update another fields, not 'executor')
account status back with:
UPDATE `account` SET `executor` = NULL WHERE `executor` = 2727 AND `id` = 1234;
- commit
Some times at step 4 mysql returns success execution status, but 0 rows affected. It happens 1 time at 10000 transactions.
What am I doing wrong? Or its mysql bug?
UPDATE:
after the observations I get the following:
1) first we do
UPDATE `account` SET `executor` = 2727 WHERE `executor` is NULL AND `id` = 1234;
2) transaction blocks record
3) during transaction I do
`UPDATE `account` SET `balance` = 1 WHERE `id` = 1234;`
4) after this query
SELECT `executor` FROM `account` WHERE `id`=1234
gives result 2727
after several repetitions of points 3 and 4 we get result executor
=NULL... or 0, as I write the result to a variable with type int, but this is likely all the same NULL... but it is not so important.. in any case executor ceased to be a value 2727
further transaction is rolled back... if again repeat operation, everything is fine without resetting value of executor...