MySQL Forums
Forum List  »  InnoDB

Re: Query id on SHOW INNODB STATUS
Posted by: Rick James
Date: April 09, 2012 07:51AM

> About the innodb_lock_wait_timeout, I had no choice and put this value in order to prevent the developper's transaction from restarting...

No. You have to beat on the developers to write transactions that don't last so long!

An InnoDB transaction should not last more than a couple of seconds. If it does, they need to design there own "locks". If they need tips on how to do this, get them to respond to this thread.

What language are they using? What are they doing that needs such a long lock?

Example (job processing):

1. "acquire" an item:
BEGIN;
SELECT id ... WHERE who_owns IS NULL AND ... FOR UPDATE -- lock for an item to work on
UPDATE ... SET who_owns = 'me', acquisition_time = NOW(), ... WHERE id = ...;
test -- if the UPDATE fails, then someone else grabbed it, so ROLLBACK, and do not continue.
COMMIT;

2. Work with that "item" for a long time

3. "release" the item:
BEGIN;
UPDATE ... SET who_owns = NULL, completion_time = NOW(), ... WHERE id = ...
COMMIT;

Another job should probably test this table periodically, looking for orphaned items. That is, items that were acquired hours ago, but not yet released. `who_owns` tells you who is 'out to lunch'.

Options: ReplyQuote


Subject
Views
Written By
Posted
9514
April 05, 2012 03:47AM
3022
April 05, 2012 07:20AM
2779
April 06, 2012 09:05PM
3646
April 07, 2012 04:22AM
2850
April 08, 2012 08:18AM
2251
April 08, 2012 11:38AM
Re: Query id on SHOW INNODB STATUS
2717
April 09, 2012 07:51AM
2363
April 10, 2012 06:04AM


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.