MySQL Forums
Forum List  »  InnoDB

Re: innodb deadlock on UPDATE
Posted by: Rick James
Date: July 17, 2015 03:43PM

> I want to keep things simple.

"Simple" instead of "correct"? For example:

BEGIN;
$ct = SELECT `count` FROM table WHERE ...; -- Without FOR UPDATE
...
UPDATE table SET `count` = $ct+1;
COMMIT;

During the "..." a different transaction could increment `count`, thereby messing up the UPDATE.

Sure, doing "SET count = count + 1" might be a solution. But not if the `count` from the SELECT is used to decide whether or not to do the UPDATE.

> thousands witin each transaction

This may not be wise. Can it be broken into smaller "transactions" and still provide the desired integrity?

Options: ReplyQuote


Subject
Views
Written By
Posted
2068
July 06, 2015 09:37AM
933
July 08, 2015 07:24PM
1342
July 08, 2015 09:52PM
1016
July 09, 2015 11:52PM
949
July 15, 2015 12:00PM
Re: innodb deadlock on UPDATE
883
July 17, 2015 03:43PM
848
July 17, 2015 04:42PM
843
July 24, 2015 03:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.