Skip navigation links

MySQL Forums :: InnoDB :: Query id on SHOW INNODB STATUS


Advanced Search

Re: Query id on SHOW INNODB STATUS
Posted by: Kin JOY ()
Date: April 10, 2012 06:04AM

Rick James Wrote:
-------------------------------------------------------
> > 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'.

It's exactly what I have done, I proved where was the problem, what caused the lock. I told them that we have two solutions to improve the current situation:

- They have to stop doing the same multiple queries, improve them and more importantly keep transactions short.
- Or, set the isolation level at ReadCommited with the drawbacks that come with it.

Anyway, thanks for your help, it's a tricky question. I even searched on MySQLperformanceblog and Baron Shwartz, Peter Zaitsev's book, they don't have my answer...

Regards,

Kin



Edited 1 time(s). Last edit at 04/10/2012 06:05AM by Kin JOY.

Options: ReplyQuote


Subject Views Written By Posted
Query id on SHOW INNODB STATUS 1664 Kin JOY 04/05/2012 03:47AM
Re: Query id on SHOW INNODB STATUS 705 Kin JOY 04/05/2012 07:20AM
Re: Query id on SHOW INNODB STATUS 712 Rick James 04/06/2012 09:05PM
Re: Query id on SHOW INNODB STATUS 843 Kin JOY 04/07/2012 04:22AM
Re: Query id on SHOW INNODB STATUS 712 Rick James 04/08/2012 08:18AM
Re: Query id on SHOW INNODB STATUS 605 Kin JOY 04/08/2012 11:38AM
Re: Query id on SHOW INNODB STATUS 979 Rick James 04/09/2012 07:51AM
Re: Query id on SHOW INNODB STATUS 700 Kin JOY 04/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.